Avoid losing information when using Debuginfo.from_location#2103
Avoid losing information when using Debuginfo.from_location#2103trefis merged 1 commit intoocaml:trunkfrom
Conversation
|
(cc @mshinwell ) |
|
We looked at the code collectively this morning (me and Noémie, Basile, Axel, Maxime, Alexandre, Hamza). Is it possible to write tests for this problem? (You forgot to add a Changes entry) There are two places in the code where the four current fields are used; should they be edited to also take the new fields into account?
Otherwise the change looks nice and useful. Thanks! |
020a9f5 to
4975909
Compare
|
Thanks to all of you for the thorough review!
I don't think there's anything to do in this function indeed.
Good catch! Fixed.
I added a few tests in
I wasn't sure if it was needed for this kind of change. If you think it is, in which section should it belong? |
|
Debuginfo is not part of |
|
Re. Changes, I think you can go no-changelog on this one, but I wasn't sure so I assumed it was a mistake. (You could use the |
4975909 to
e18aa6c
Compare
|
OK. I removed the commit with the buggy tests. |
|
@gasche ping |
|
Only the "changes" check fails on travis (I've just restarted it but it really doesn't care about your "no-change-entry-needed" label). |
It seems the middle end can emit semi-broken locations.
fun x -> Debuginfo.(to_location (from_location x))is not the identity, because aDebuginfo.tcontains strictly less information that aLocation.t. In particular, it forgets about the position of start/end points in the input, and only remembers their position relative to the beginning of the line.Currently this goes unnoticed because
Debuginfo.to_locationproduces a mock location that is printed the same as the original one when callingLocation.print_loc. However, this breaks #2096 in which I rely on the full information of the locations to look for the corresponding source code in the input.This PR adds the missing information in
Debuginfo.itemso thatto_location o from_locationcan be the identity (except for locations that would contain different filenames for start/end but I don't think this happens).