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
does not trigger disambiguation: "the tokens C<T> are interpreted as a namespace-or-type-name with a type-argument-list due to being on the right-hand side of the is operator (§13.11.1). Because C<T> parses as a namespace-or-type-name, not a simple-name, member-access, or pointer-member-access, the above rule does not apply, and it is considered to have a type-argument-list regardless of the token that follows."
As I show below, the token that follows needs to matter.
It is true that the disambiguation rules don't handle this case, but that still leaves the question as to why the right-hand-side of the is expression is the type C<T> rather than the type C followed by less-than operator. The following program demonstrates that this could be a valid parse:
publicclassExample{publicstaticvoidMain(){}staticboolM(objecty,Cc,Tt,Zz){// return ((y is C) < t) > z;return y isC<t> z;}}classC{}classT{publicstaticbooloperator<(boolleft,Tright)=>true;publicstaticbooloperator>(boolleft,Tright)=>false;}classZ{publicstaticbooloperator<(boolleft,Zright)=>true;publicstaticbooloperator>(boolleft,Zright)=>false;}
Similarly, we may need to handle an expression such as F(e is G<A, B>7).
We might consider modifying the precedence of the is and as operators to forbid this. I believe existing compilers won't parse these examples.
The text was updated successfully, but these errors were encountered:
jskeet
added
meeting: discuss
This issue should be discussed at the next TC49-TG2 meeting
type: bug
The Standard does not describe the language as intended or implemented
labels
Jan 12, 2021
Just an FYI, we'll also touch this section to address a separate issue re adding support for out variables in V7. See #44, which might or might not impact how we deal with this issue now.
The resolution we took in https://github.com/ECMA-TC49-TG2/spec/issues/880 does not appear to be correct. The current spec now says that the example
does not trigger disambiguation: "the tokens
C<T>
are interpreted as a namespace-or-type-name with a type-argument-list due to being on the right-hand side of theis
operator (§13.11.1). BecauseC<T>
parses as a namespace-or-type-name, not a simple-name, member-access, or pointer-member-access, the above rule does not apply, and it is considered to have a type-argument-list regardless of the token that follows."As I show below, the token that follows needs to matter.
It is true that the disambiguation rules don't handle this case, but that still leaves the question as to why the right-hand-side of the
is
expression is the typeC<T>
rather than the typeC
followed by less-than operator. The following program demonstrates that this could be a valid parse:Similarly, we may need to handle an expression such as
F(e is G<A, B>7)
.We might consider modifying the precedence of the
is
andas
operators to forbid this. I believe existing compilers won't parse these examples.The text was updated successfully, but these errors were encountered: