Skip to content

How to get symbol name from a SymbolResult #2759

Open

Description

@KathleenDollard

I may be overlooking something obvious, or just have spaced on this...

I want to transform the ParseResult for combining with additional failures that will be grouped by symbol name.

I can get the SymbolResult from ParseResult.Errors.First().SymbolResult

However, I do not see how to get the Symbol from the SymbolResult (which seems odd enough I am pretty sure I have overlooked something).

@jonsequitur

Activity

  1. jonsequitur commented on Jan 13, 2026

    @jonsequitur
    Contributor

    SymbolResult is abstract. You can pattern match to the derived types like this and get their associated symbols like this:

    Symbol currentSymbol = currentSymbolResult switch
    {
    ArgumentResult argumentResult => argumentResult.Argument,
    OptionResult optionResult => optionResult.Option,
    DirectiveResult directiveResult => directiveResult.Directive,
    _ => ((CommandResult)currentSymbolResult).Command
    };

  2. cbersch commented on Mar 6, 2026

    @cbersch

    @jonsequitur Couldn't the SymbolResult have a Symbol property?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions