Area-CompilersBugConcept-Diagnostic ClarityFeature - Ref Locals and Returnshelp wanted
Repository-Metriken
- Stars
- (20.414 Sterne)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)
Beschreibung
Valid code:
static void Test(int x)
{
ref int y = ref x;
}
Invalid code:
static void Test(int x)
{
const ref int y = ref x;
}
Expected: an error message on const specifying that you cannot use ref and const modifiers together.
Found: parser fails with the following errors:

- CS1525 Invalid expression term 'ref'
- CS1002 ; expected
- CS1001 Identifier expected
- CS8172 Cannot initialize a by-reference variable with a value
- CS0118 'x' is a variable but is used like a type
- CS8174 A declaration of a by-reference variable must have an initializer