dotnet/roslyn

Improve parser error recovery for misplaced `ref` modifier of a struct declaration

Ouverte

#84 734 ouverte le 2 août 2026

 (5 commentaires) (0 réaction) (0 personne assignée)C# (4 257 forks)batch import
Area-CompilersFeature - Ref Fieldshelp wanted

Métriques du dépôt

Stars
 (20 414 étoiles)
Métriques de merge PR
 (Merge moyen 6j 17h) (256 PRs mergées en 30 j)

Description

Case 1:

Snippet:

ref public struct MyStruct;

Expected: ref is in the modifiers list for MyStruct, error about its misplacement

Actual: ref is a part of RefTypeSyntax of IncompleteMemberSyntax while StructDeclarationSyntax starts from a public token. The error is 'Type expected' on public token

Case 2:

Snippet:

partial ref struct MyStruct;

Expected: partial is in the modifiers list for MyStruct, error about its misplacement

Actual: partial is its own IncompleteMemberSyntax. The error is on ref keyword saying about its misplacement instead

Guide contributeur