SyntaxFactory and discards #35558
Labels
Area-Compilers
Concept-API
This issue involves adding, removing, clarification, or modification of an API.
Feature Request
help wanted
The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Version Used: 3.0.0
Consider the following code:
It parses a simple piece of code and compiles it. Then, it replaces the parsed identifier
_
with one created usingSyntaxFactory.IdentifierName("_")
and compiles again.I would expect both to compile by interpreting the
_
as a discard, but they don't; the output of the program above is:As far as I can tell, this happens because the identifier token created by
SyntaxFactory
does not have its contextual kind set up correctly:This prints:
There is an overload of
SyntaxFactory.Identifier
which acceptsSyntaxKind contextualKind
, so it is possible to useSyntaxFactory
to create the right identifier token. But shouldn't the simpler overload do this automatically?The text was updated successfully, but these errors were encountered: