"Andrey Simanovsky" <an*******@discussions.microsoft.com> wrote in message
news:18****************************@phx.gbl...
VS 2003 C# compiler (as well as Rotor one) compiles the
following code:
System.Console.WriteLine(o2 as C + (o2 as C)); //!?
System.Console.WriteLine(o2 as C << 1); //!?
whereas the syntactic grammar of the specification says
(including the .doc on msdn said to reflect the actual
compiler) that this code is invalid: 'o2 as C' cannot be
deduced from an additive-expression or a shift-expression
non-terminals.
Are you trying to write this yourself? If you are, chances are you aren't
writing something correctly.
The as expression should be something like:
relational-expression as type
where type eventually resolves down to an identifier, a qualified
identifier(name.name.name), or one of the built in type keywords(object,
string, etc). That shouldn't be ambigious with a shift expression. The
additive and shift expressions would operate on the *result* of the as
expression, not C.
Atleast, thats what my reading of the grammer says.