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.
Follow-up of #1812. Prior to extending match expressions with full pattern matching, this PR adds support for bare enum tags, which will be needed to be able to handle the existing enum tags match expressions.
In the end, I tend to agree with @vkleen 's comment, and contrary to what the original description of #1812 said, enum tags shouldn't in fact be treated as constants but rather as special cases of enum variants. It'll also make the transition easier, if we decide to go with an explicit
Unit
type and really have them be the same thing.There is a bit of fuss around lazyness for patterns. Right now,
let 'Foo x = <exp> in <body>
doesn't fire any check if<body>
doesn't usex
, which is in line with lazy contracts, but might be surprising. Then what should do a pattern that doesn't bind any variable? In this PR, I went with the answer that we should add an artificial dependency (basically,seq
), otherwiselet 'Foo = x in <body>
would always succeed, whateverx
is, which is unreasonable.Thinking ahead toward pattern in match expression, patterns will have to evaluate arguments up to a point to decide which branch to take (and hence be more eager than current destructuring patterns). Although it's technically backward-incompatible, I think we should do the same with destructuring. Some programs that use to evaluate might suddenly break, but it's arguably a "should have broke earlier" case - adding eagerly error reporting isn't the same as breaking entirely fine programs. If we do so, we can just get rid of those lazyness shenanigans.
But we can discuss this question further.