Skip to content

Commit 8d731e6

Browse files
Add Debug.Assert for catch variable in DeclaringSyntaxReferences
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
1 parent 233cdab commit 8d731e6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Compilers/VisualBasic/Portable/Symbols/Source/LocalSymbol.vb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
928928
If _modifiedIdentifierOpt IsNot Nothing Then
929929
Return ImmutableArray.Create(Of SyntaxReference)(_modifiedIdentifierOpt.GetReference())
930930
Else
931-
' For catch variables (and potentially other cases), there is no ModifiedIdentifierSyntax.
932-
' Fall back to using the identifier token's parent (e.g., IdentifierNameSyntax for catch).
931+
' Only catch variables should have Nothing for _modifiedIdentifierOpt
932+
Debug.Assert(DeclarationKind = LocalDeclarationKind.Catch)
933+
' For catch variables, there is no ModifiedIdentifierSyntax.
934+
' Fall back to using the identifier token's parent (IdentifierNameSyntax).
933935
Return ImmutableArray.Create(_identifierToken.Parent.GetReference())
934936
End If
935937
End Select

0 commit comments

Comments
 (0)