-
-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
Problem
C# 12 allows primary constructors on classes with base class invocation, but this syntax produces an ERROR node.
Reproduction
public class MyException(int id, string message) : Exception($"Error {id}: {message}");Expected
Should parse similarly to how records with primary constructors are handled (using primary_constructor_base_type).
Actual
Produces an ERROR node wrapping the entire class declaration.
Working cases
| Syntax | Result |
|---|---|
public record Foo(int x) : Base(x); |
✅ Parses correctly |
public class Foo(int x) { } |
✅ Parses correctly |
public class Foo(int x) : Base(x); |
❌ ERROR node |
Analysis
Looking at the grammar, primary_constructor_base_type appears to only be included in record_declaration, not in class_declaration. The C# 12 spec allows this syntax on all class types.
Reference
Environment
- tree-sitter-c-sharp version: 0.23.1
Metadata
Metadata
Assignees
Labels
No labels