-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Parse failure with <
after a cast destination type.
#60146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a fun cross-language disambiguation problem. Consider the (related) classical ambiguous parsing example:
Is For some context, Rust has the exact same problem. |
That same Rust thread describes the C# heuristic, which makes a lot of sense to me. |
The current Rust-y answer of using lookahead to emit an extremely helpful diagnostic also works here. The C# solution doesn't feel right to me not just because it fails the "some amount of unbounded lookup" test, but because it precludes the language adopting non-type type parameter arguments without some extra disambiguating tokens.
|
@CodaFi Thank you for this detailed response. I understand the first problem with some ambiguity concerning |
Description
When dealing with cast destination type and a
<
operator after it, the compiler assumes that the generic arguments list is going to follow the<
and produces anexpected type
error.Steps To Reproduce
Steps to reproduce the behavior:
let _ = 1 as Int16 < 7
.expected type
error.Expected behavior
There should be no
expected type
error, since<
in this context is not supposed to be followed by a generic arguments list.Environment
Additional context
I fixed issue #43053 which addresses similar problem, but with the
<<
operator.The text was updated successfully, but these errors were encountered: