[ fix ] Backticked names cannot be used as prefix operators#3740
[ fix ] Backticked names cannot be used as prefix operators#3740spcfox wants to merge 3 commits intoidris-lang:mainfrom
Conversation
|
Is there any chance we could have a more helpful message suggesting the use of |
1d899a3 to
0cfd254
Compare
Not sure if this error can be easily added during parsing. I couldn't get it to work. |
|
@andrevidela, could we add this kind of error to the parser? Perhaps we shouldn't modify the parser itself and instead throw the error during desugaring? I think it’s better to make it a parsing error, but I couldn't figure out how to add an informative error message. |
|
In my experience, it's easier to catch this kind of error during desugaring, we have more contextual information than during parsing and it keeps the parser simple. It also keeps the parse tree semantically simple, if we catch the backtick misuse at parsing time, we still produce a value of type |
38e1a76 to
dd6866e
Compare
|
Ok, now the error is handled during desugaring |
5aad660 to
bd4f63d
Compare
| ^^^^^^ | ||
|
|
||
| Possible solutions: | ||
| - Use section: (`Elem` _ . fst) |
There was a problem hiding this comment.
Should the section not be
(`Elem` _) . fst
?
There was a problem hiding this comment.
Should we be guessing the parenthesis placement here? Both cases could potentially be correct
There was a problem hiding this comment.
The internal error occurred in the shunting algorithm, which reorders operators according to their precedence. That’s why I added this check before it. We could potentially run it, but I’m not sure it would be helpful
|
|
||
| Possible solutions: | ||
| - Use section: (`Elem` _ . fst) | ||
| - Use application: Elem _ . fst |
There was a problem hiding this comment.
This application has a different meaning as _ is now for the first argument rather than the second one.
There was a problem hiding this comment.
We don’t know what the user intended. In the first case, I'm suggesting the most likely option — a section. But it’s also possible that the backticks were just a typo.
There was a problem hiding this comment.
yeah we can't run the typechecker at this stage to know which one is the one that the user meant. I think this is fine as the user will probably try both and pick the one that works
Description
Fixes #3550
Self-check
implementation, I have updated
CHANGELOG_NEXT.md