Rename user-defined holes on naming conflict #640
Closed
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.
Personally, I often find myself duplicating hole names if I want to postpone work on some piece of my code to a later time (using something like
?later
). This worked perfectly with Idris 1, but Idris 2 isn't so happy about code likeerroring out on the second
?later
because it's already defined.This PR addresses this. In particular, it renames the holes roughly following Idris 1 behaviour (so that the first
?later
above remains as?later
, and the second one becomes?later1
). Moreover, I've checked the REPL recognizes this correctly and shows the type of the first hole when asked for:t later
, and the type of the second one on:t later1
.It only renames holes if they conflict with another hole and not a user-defined function, so things like
are still erroneous. I'm quite new to the Idris 2 internals though, so I might have got that check wrong, of course.
One thing missing here is tests. I'm not sure what's the right
tests/
subdir to put this in, so, if this change is not frowned upon, I'd be happy to add those!