You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to compiler error CS0439, extern_alias_directive must precede all other elements defined in the namespace. Meaning, only comments, preprocessor directives and extern alias can precede another extern alias .
e.g. this valid case
externaliasA;externFooB;usingAT=A::NS.T;
becomes invalid if we swap the order of extern and extern alias:
externFooB;externaliasA;usingAT=A::NS.T;
tree-sitter-c-sharp however does not error out in this case but instead changes:
tree-sitter-c-sharp is not as exact as a compiler and is more forgiving as it has a different role. We (and other tree-sitter grammars) intentionally wrote the grammars to support snippets of code - so for example we supported top-level statements such as just writing
intc=0;
Long before C#/Roslyn actually supported that itself. In this way tree-sitter-c-sharp and other tree-sitter grammars could be used in more places than an actual compiler/strict parser.
It looks to me that this is one of those cases where it is doing just that. There are other places as well where we do not force strict order - this is also intentional.
I agree that the strictness of parser not necessarily match roslyn.
However, in this case, emitting extern_alias_directive in first case, but not the second (and treating alias as a separate directive) makes an interesting edge case. i.e. it looks like we do respond to CS0439 rules to certain degree in a sense that we seemingly do classify when it is preceded by another statement vs. when it isn't.
According to compiler error CS0439,
extern_alias_directive
must precede all other elements defined in the namespace. Meaning, only comments, preprocessor directives andextern alias
can precede anotherextern alias
.e.g. this valid case
becomes invalid if we swap the order of
extern
andextern alias
:tree-sitter-c-sharp however does not error out in this case but instead changes:
to
after the swap (i.e.
alias
becomes a separate typeidentifier
).Is this an intentional behavior?
The text was updated successfully, but these errors were encountered: