dotnet/roslyn

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

開放

#84,734 建立於 2026年8月2日

 (5 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-CompilersFeature - Ref Fieldshelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

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

貢獻者指南