Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new warning for suspicious octal constants #6291

Closed
vicuna opened this issue Jan 9, 2014 · 5 comments
Closed

Add a new warning for suspicious octal constants #6291

vicuna opened this issue Jan 9, 2014 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Jan 9, 2014

Original bug ID: 6291
Reporter: @protz
Assigned to: @protz
Status: assigned (set by @protz on 2014-01-09T13:10:29Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.02.0+dev
Category: lexing and parsing
Tags: patch
Monitored by: @gasche

Bug description

Following the comments from http://roscidus.com/blog/blog/2014/01/07/ocaml-the-bugs-so-far/, I implemented a new warning that is triggered by decimal constants of the form "0n..." where n <> 0.

jonathan@ramona:~/Code/ocaml (trunk) $ cat /tmp/test.ml 
let x = 0123;;
let y = 123;;
jonathan@ramona:~/Code/ocaml (trunk) $ /usr/local/bin/ocaml -warn-error /tmp/test.ml
File "/tmp/test.ml", line 1, characters 8-12:
Warning 48: 0123 looks like you wrote an octal constant.
 Did you mean 0o123?

Damien, somehow I can't turn the warning off with -warn-error -48, and +48 seems to make it fatal. Am I missing something?

File attachments

@vicuna
Copy link
Author

vicuna commented Jan 9, 2014

Comment author: @protz

I forgot to mention that the patch adds documentation in the man page for warnings 46 and 47 while we're at it. I know who implemented these warnings but I won't blame them in public ;-).

@vicuna
Copy link
Author

vicuna commented Jan 9, 2014

Comment author: @yallop

Why is there a warning for 0700 but not for 0070?

@vicuna
Copy link
Author

vicuna commented Jan 9, 2014

Comment author: @protz

I somehow suspected that if people are padding with more than one zero, they probably don't "mean" octal, but that's just a wild guess. I can warn for any leading zeroes if that sounds better.

@vicuna
Copy link
Author

vicuna commented Jan 17, 2014

Comment author: @damiendoligez

I think it's better to warn for all leading zeroes. Easier to document, too.

To disable warning 48, you should use -w -48, not -warn-error.

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant