bugfix: make view Float.mod.doc
not crash
#5533
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #5520
This is a weird one.
view Float.mod.doc
caused UCM to crash, ultimately because we were callingName.splits
on an absolute name, which you aren't supposed to do.The fix implemented here is to simply not call
Name.splits
on absolute names. This seems fine, because we are only callingName.splits
on names in order to count their uses, for the purpose of possibly inserting ause
clause to clean some stuff up. So, a consequence of this particular fix is we won't ever (say) shorten something liketo
Given how incredibly fragile this particular part of term parsing and printing is, with respect to variable capture, I think that's an ok compromise.
On to the root cause: I think there is an issue in the doc parser. Take a look at a rendering of part of
Float.mod.doc
:Notice that
Float.-
is a clickable thing, but none ofFloat.floor
,Float./
, orFloat.*
are. Why is that?Simplifying the example a bit,
this comes out of the doc parser as
Note that
Float.*
is free, butFloat.floor
is bound for some reason (which is especially curious since I originally wrote the expression asfloor
and let TDNR resolve it toFloat.floor
). That ultimately explains why the "avoid shadowing" logic in our term printer kicks in and has to render someFloat.*
with a leading dot, due to the (overly-conservative) logic that only cares whether a variable is bound anywhere in a term.Test coverage
I've only tested this manually, but could add a transcript that tries to distill down the problem and solution. I'm hesitant to do that, though, because I suspect a fix to the doc parser would essentially make that transcript not really test anything important. So, it's plausible (to me) that a manual test is fine for this one.