Struct SymbolResolutionResult
The result of resolving an identifier name against a scope. Mirrors the other
*Result records: it carries a payload (the bound Symbol), or a diagnostic,
never both.
public readonly record struct SymbolResolutionResult : IEquatable<SymbolResolutionResult>
- Implements
- Inherited Members
Remarks
The resolver reports which compile-time error a lookup hit, not a located VBCompileErrorInfo: it does not know where the reference is. The caller, which has the syntax node, builds the diagnostic from ErrorCode and Candidates. The errors a lookup hits:
- Duplicate declaration in current scope: the name is declared more than once within one module or procedure.
- Ambiguous name detected: the name resolves in more than one enclosing scope (members promoted from different modules or references); the reference must qualify it.
- Definitions of property procedures for the same property are inconsistent: the name resolves to a
property's
Get/Let/Setaccessors, but their declarations are not a valid property (MS-VBAL §5.3.1.7). - Argument required for Property Let or Property Set: the name resolves to a
Property LetorProperty Setdeclared with no parameters at all, so it has no value parameter (MS-VBAL §5.3.1.5:value-paramis never bracketed).
Constructors
SymbolResolutionResult(Symbol?, RDCoreDiagnosticCode?, ImmutableArray<Symbol>)
The result of resolving an identifier name against a scope. Mirrors the other
*Result records: it carries a payload (the bound Symbol), or a diagnostic,
never both.
public SymbolResolutionResult(Symbol? Symbol, RDCoreDiagnosticCode? ErrorCode, ImmutableArray<Symbol> Candidates)
Parameters
SymbolSymbolThe bound symbol, or
nullwhen the name is unbound or in error.ErrorCodeRDCoreDiagnosticCode?The diagnostic code of the compile-time error the lookup hit (a CompilePrefix code), or
null.CandidatesImmutableArray<Symbol>The colliding declarations for an error result; empty otherwise.
Remarks
The resolver reports which compile-time error a lookup hit, not a located VBCompileErrorInfo: it does not know where the reference is. The caller, which has the syntax node, builds the diagnostic from ErrorCode and Candidates. The errors a lookup hits:
- Duplicate declaration in current scope: the name is declared more than once within one module or procedure.
- Ambiguous name detected: the name resolves in more than one enclosing scope (members promoted from different modules or references); the reference must qualify it.
- Definitions of property procedures for the same property are inconsistent: the name resolves to a
property's
Get/Let/Setaccessors, but their declarations are not a valid property (MS-VBAL §5.3.1.7). - Argument required for Property Let or Property Set: the name resolves to a
Property LetorProperty Setdeclared with no parameters at all, so it has no value parameter (MS-VBAL §5.3.1.5:value-paramis never bracketed).
Fields
Unbound
The name is declared nowhere visible from the origin scope.
public static readonly SymbolResolutionResult Unbound
Field Value
Properties
Candidates
The colliding declarations for an error result; empty otherwise.
public ImmutableArray<Symbol> Candidates { get; init; }
Property Value
ErrorCode
The diagnostic code of the compile-time error the lookup hit (a CompilePrefix code), or null.
public RDCoreDiagnosticCode? ErrorCode { get; init; }
Property Value
IsError
true when the lookup hit a compile-time error.
public bool IsError { get; }
Property Value
IsResolved
true when the name bound to exactly one symbol.
public bool IsResolved { get; }
Property Value
IsUnbound
true when no scope declared the name: not an error in itself.
public bool IsUnbound { get; }
Property Value
Symbol
The bound symbol, or null when the name is unbound or in error.
public Symbol? Symbol { get; init; }
Property Value
Methods
Resolved(Symbol)
A successful resolution to symbol.
public static SymbolResolutionResult Resolved(Symbol symbol)
Parameters
symbolSymbol