roslyn: Why C# compiler accepts and compiles so obvious error?
Version Used: C# 6
Steps to Reproduce:
AnyType Identifier { get { return Identifier; } }
AnyType Identifier => Identifier;
Expected Behavior: Fail to compile
Actual Behavior: Compiles, at run-time runs into infinite loop until Stack Overflow
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 19 (8 by maintainers)
That’s perfectly legal syntax. The fact that you have an unbounded and uncontrolled recursion issue is a logical one. (To note, I do think that a compiler warning or a default analyzer warning would be useful. Perhaps a compiler error in so obvious a case, but new errors/warnings would probably only be considered in strict mode.)
See #7695
The compiler’s main job is to implement the language specification. The Analyzers area covers proposed new warnings that are not required by the language specification, whether implemented in the compiler or elsewhere.
I’m treating this as a feature request for a new warning.
@ddur When you say “this is definitely a compiler task”, are you ruling out it being implemented by a (non-compiler) analyzer?
Hi @gafter I’m glad you added Area-Analyzers but why removing Area-Compilers? Why you refuse or do not want compiler improved? Is it because of competition with another team or company?