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
In a match statement the case _ stands for all the remaining values not yet considered. This works fine when only one expression is being matched.If there is more than one expression then the pattern language incorrectly treats _ as a "any value" wildcard which in turn creates errors when there are none. The simplest example is perhaps something like
u8 N = 4;
match (N) {
(4) : result = 2;
(_) : result = 44;
}
The first case tests if value is 4 and the second case matches any value except 4. Thus no ambiguities exist because the cases are mutually exclusive and in this case result will become 2. Consider now the similarly looking match statement that is
u8 M = 5;
match (M,N) {
(5,4) : result = 2;
(5,_) : result = 44;
(_,4) : result = 55;
(_,_) : result = 66;
}
which prints error messages stating that cases 1 and 2 are ambiguous erroneously. the fist case case checks if M is 5 and N is 4 and the second case should be checking if M is 5 and N is not 4 but instead it is checking for M being 5 and N being any value which would be ambiguous with first case.
The reason I can say with confidence that there is a bug here is that the match statement is an operation brought into the pattern language from rust and running the two matches in rust sets result to be 2 and there are no ambiguity errors
The text was updated successfully, but these errors were encountered:
In a match statement the case
_
stands for all the remaining values not yet considered. This works fine when only one expression is being matched.If there is more than one expression then the pattern language incorrectly treats_
as a "any value" wildcard which in turn creates errors when there are none. The simplest example is perhaps something likeThe first case tests if value is 4 and the second case matches any value except 4. Thus no ambiguities exist because the cases are mutually exclusive and in this case
result
will become 2. Consider now the similarly looking match statement that iswhich prints error messages stating that cases 1 and 2 are ambiguous erroneously. the fist case case checks if
M
is 5 andN
is 4 and the second case should be checking ifM
is 5 andN
is not 4 but instead it is checking forM
being 5 andN
being any value which would be ambiguous with first case.The reason I can say with confidence that there is a bug here is that the match statement is an operation brought into the pattern language from rust and running the two matches in rust sets result to be 2 and there are no ambiguity errors
The text was updated successfully, but these errors were encountered: