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
Notice that there is a special case for the condition expression "except struct expression." Not sure if I'm correct, but I think this meant to specify the cases that result in ambiguity, such as
if A{} {
}
Where A is a struct. In this case, I assume the parser/compiler cannot determine whether A itself is a variable and the following {} is the block, or alternatively, A{} as a whole is an expression.
However, there are other cases leading to compile errors even if the condition expression is not struct expression, below are two examples:
Adding paratheses around the two expressions will resolve the error.
I feel like this needs to be better explained in the reference other than "except struct expression," as the expression does not have to be struct expression to induce error.
If I understood the problem correctly, I'm willing to submit a PR for this using similar examples, please point me out if the original description is intentional.
The text was updated successfully, but these errors were encountered:
Thanks for the report! I agree that the current documentation is incomplete/lacking/wrong. This is currently tracked in #569, so closing as a duplicate of that.
The grammar for
if
expressions is described as:Notice that there is a special case for the condition expression "except struct expression." Not sure if I'm correct, but I think this meant to specify the cases that result in ambiguity, such as
Where
A
is a struct. In this case, I assume the parser/compiler cannot determine whetherA
itself is a variable and the following{}
is the block, or alternatively,A{}
as a whole is an expression.However, there are other cases leading to compile errors even if the condition expression is not struct expression, below are two examples:
In ex1 a method call expression is shown, and in ex2 an operator expression is shown.
Adding paratheses around the two expressions will resolve the error.
I feel like this needs to be better explained in the reference other than "except struct expression," as the expression does not have to be struct expression to induce error.
If I understood the problem correctly, I'm willing to submit a PR for this using similar examples, please point me out if the original description is intentional.
The text was updated successfully, but these errors were encountered: