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 locations and ghost locations #5142

Closed
vicuna opened this issue Sep 3, 2010 · 6 comments
Closed

wrong error locations and ghost locations #5142

vicuna opened this issue Sep 3, 2010 · 6 comments
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 3, 2010

Original bug ID: 5142
Reporter: Hendrik Tews
Assigned to: @xclerc
Status: closed (set by @damiendoligez on 2012-09-19T12:05:39Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.0
Target version: 4.00.1+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Related to: #5090
Monitored by: @gasche "Alexander Ulrich" "Sergey Plaksin" hnrgrgr @ygrek furuse @mjambon

Bug description

Try to compile Loc.ml from the ocaml sources! The first point is
that the (* camlp4r *) comment at the top of the file is
misleading. Needed is actually camlp4r Camlp4DebugParser.cmo!

A first run of

ocamlc -c -pp 'camlp4rf Camlp4DebugParser.cmo' Loc.ml

gives

File "Loc.ml", line 177, characters 16-58:
Error: Unbound module Camlp4_import

However, the unknown identifier Camlp4_import is on line 176. The
location reported here is wrong.

The next try with

ocamlc -c -pp 'camlp4r Camlp4DebugParser.cmo' -I +camlp4 Loc.ml

gives

File "ghost-location", line 295, characters 0--8932:
Error: Unbound module ErrorHandler

The filename and the characters are wrong here, though the line
number is correct.

File attachments

@vicuna
Copy link
Author

vicuna commented Mar 17, 2011

Comment author: till

The problem seems to be in the code that merges the locations. A simpler test of appears to be the same bug would be:

tmp> cat t.ml
type t = int
tmp> camlp4o t.ml -add_locations
(loc: ["t.ml": 1:0-12 1:12])
type (loc: ["t.ml": 1:5-12 1:12])
t =
(loc: ["ghost-location": 1:9-0 1:0 (ghost)])
(loc: ["ghost-location": 1:9-0 1:0 (ghost)])
(loc: ["ghost-location": 1:9-0 1:0 (ghost)])
int

The attached patch should fix this.

@vicuna
Copy link
Author

vicuna commented Mar 18, 2011

Comment author: @ygrek

Hm, am I the only one to think that { (b) with stop = b.stop } is waste of characters (whatever b is)?

@vicuna
Copy link
Author

vicuna commented Mar 18, 2011

Comment author: till

Indeed. That's because this line should have been:
{ (b) with start = a.start }
That's a bit embarrassing for a patch this small. Uploaded a corrected patch.

@vicuna
Copy link
Author

vicuna commented Apr 5, 2011

Comment author: till

It turns out that keeping the ghost=True in the resulting location is also important (although I couldn't really figure out where it was used in camlp4). Hopefully that's the last regression on that bug fix. I'll upload a patch with the bootstrapping soon.

@vicuna
Copy link
Author

vicuna commented Apr 7, 2011

Comment author: till

Seems fixed in the 3.12 svn (at least for my problem cases).

@vicuna
Copy link
Author

vicuna commented Sep 19, 2012

Comment author: @damiendoligez

The second problem is fixed in 3.12.1 and the first one in 4.00.0.

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