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

Wrong error location with records #5369

Closed
vicuna opened this Issue Oct 4, 2011 · 4 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Oct 4, 2011

Original bug ID: 5369
Reporter: Julien Signoles
Assigned to: @damiendoligez
Status: closed (set by @damiendoligez on 2011-12-23T16:58:07Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.1
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @hcarty

Bug description

Consider the following buggy program:

=== a.ml ===
let a = { A.a = 0 }

$ ocamlc -c a.ml
File "a.ml", line 3, characters 16-17:
Error: Unbound module A

The error is located on 0. It should be located on A (or A.a).

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 5, 2011

Comment author: @damiendoligez

This is more or less done on purpose. The parser doesn't save the location information for the label itself, so the only alternative would be to locate the error on the whole record expression (characters 8-17 in your example). It would be more accurate but less precise.

I can make the change if you have a compelling argument.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 6, 2011

Comment author: Julien Signoles

When (among others refactoring changes) you are replacing A by X.A by compiling/showing-next-error/pasting 'X.' in your favorite text editor, it is a waste of time if the error is wrongly located.

IMHO Locating the error on the whole record expression (your proposal) instead of on the innermost expression does not fully solve this issue, but perhaps it helps a little bit since you would go to the right location faster.

Also, for tools who try to use OCaml error messages to automatically fix standard mistakes, your proposal could be better than the current issue. But I'm not an expert of such tools: ask to the OCamlpro's leader ;-).

Last but not least, in static analysis tools, overapproximations are always better than more-precise-but-incorrect results...

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 10, 2011

Comment author: Julien Signoles

I just fall back on this issue. I confirm that the current behavior is very annoying since you search the error somewhere in the located area (which may be a complicated expression) and you don't understand why you don't find the offending label.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 23, 2011

Comment author: @damiendoligez

Fixed in the 3.12 branch (revision 11949). The error location is now on the whole record.

Note: in the trunk, this problem has disappeared, as a result of an (apparently) unrelated modification of the typing algorithm. The location is also on the whole record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.