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

Incorrect source file reference for OCaml warning Y (unused variable name) with ocamllex #4200

Closed
vicuna opened this issue Jan 27, 2007 · 1 comment
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 27, 2007

Original bug ID: 4200
Reporter: @dra27
Assigned to: @maranget
Status: closed (set by @xavierleroy on 2009-03-31T11:02:55Z)
Resolution: fixed
Priority: normal
Severity: text
Version: 3.09.3
Fixed in version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)

Bug description

If you bind a portion of a matched regular expression to a variable (e.g. [^ 'a'-'z' ]+ as name) and then don't use it in the lexer action block ({...}) then ocamlc issues Warning Y (by default) when you compile the .ml file.
The line number and file given for this warning refer to the ocamllex-compiled ML file and not to the actual source .mll file as other errors and warnings do.
ocamllex should insert additional # statements in the ML file before each "let foo = Lexing.sub_lexeme ..." line in its ML output.

Additional information

Of course, just inserting # {line} "{file}.mll" still means that the character reference number would be wrong, though I'm sure that some trickery with whitespace can be done to engineer the variable name in the ML file being at the same place as in the .mll file to fix this too!

Definitely a cosmetic change, though...

@vicuna
Copy link
Author

vicuna commented Jan 29, 2007

Comment author: @maranget

Arguably this is a bug, or at least a misfeature.

Thank you for reporting it.

I have modified ocamllex so as to yield source (.mll) locations
for variables that are bound with 'as'.

Committed in 3.10 branch.

--LM

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

No branches or pull requests

2 participants