You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expressions starting from _ are treated as placeholders in match cases #1025
Oh, match. The undocumented, largely untested, experimental feature that somehow people keep discovering anyway.
This sure does look like a bug, but I don't know whether this should be an error, your expected result, or something else. _ has special meaning inside match, which is complicated by the fact that _ is also used to create a partial-application function and as far as I know, every case of a match expression should be interpreted as a function (unless it isn't, like with constants).
I don't really intend to do anything to improve the state of match, unless someone feels like fully and properly specifying its behavior. The good news is, as an experimental undocumented feature, I also wouldn't feel even a tiny bit bad about ripping it out and replacing it with something else. You were all warned. 🙂
I drew an analogy to the partial application or switch's default, where only a standalone underscore has a special meaning. In those cases using _.toString wouldn't trigger anything special.
I might fix it later. For now, let this issue be a walk-around suggestion.
Activity
rhendric commentedon Mar 26, 2018
Oh,
match. The undocumented, largely untested, experimental feature that somehow people keep discovering anyway.This sure does look like a bug, but I don't know whether this should be an error, your expected result, or something else.
_has special meaning insidematch, which is complicated by the fact that_is also used to create a partial-application function and as far as I know, every case of amatchexpression should be interpreted as a function (unless it isn't, like with constants).I don't really intend to do anything to improve the state of
match, unless someone feels like fully and properly specifying its behavior. The good news is, as an experimental undocumented feature, I also wouldn't feel even a tiny bit bad about ripping it out and replacing it with something else. You were all warned. 🙂pepkin88 commentedon Mar 26, 2018
OK, fair enough.
I drew an analogy to the partial application or switch's default, where only a standalone underscore has a special meaning. In those cases using
_.toStringwouldn't trigger anything special.I might fix it later. For now, let this issue be a walk-around suggestion.
pepkin88 commentedon Apr 2, 2018
Related issue with a plausible use case scenario:
This:
compiles to:
instead of:
Although I think this feature is a real gotcha and makes sense only in the context of
match, it actually is documented.rhendric commentedon Apr 2, 2018
Ha, okay, you got me! This should be fixed.
pepkin88 commentedon Apr 2, 2018
This looks like an easy one I could tackle, but only from next week.
rhendric commentedon Apr 2, 2018
I'll hold it for you then.
anant-svc commentedon Jun 11, 2018
Hi, tried to get expected result @pepkin88 needed using below:
Result:
fix gkz#1025
fix gkz#1025
fix gkz#1025
fix gkz#1025
fix #1025