roslyn: let statement may break compatibility with a user-defined type named let

The parser doesn’t know whether or not there is a user-defined type named let, so it parses a let statement assuming that no such type exists. As a practical matter than would break existing code that uses let as the name of a type. Do we want to do anything about this?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

@DavidArno Exactly, it would only be necessary in that virtually non-existent case. To most people let x = 123; would be perfectly fine. That is assuming the parser can use the subsequent tokens to make the determination as to what kind of statement it is.

I’d feel bad for anyone working on a project where both var and let are defined as types. I’ve seen the former used by devs who hate the idea of inferred locals.

I would think user-defined types named “let” would be extremely rare, given that “let” is both lowercase and a verb. It’s great that you take breaking changes so seriously, but in this case I think it’s worth it. I really like the proposed use of the let keyword.

@DavidArno It’s a little buried in the spec, but:

The use of a pattern variables is a value, not a variable. In other words pattern variables are read-only.