Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
Dim typeChar As String = Nothing
Dim specialType = GetSpecialTypeForTypeCharacter(identifier.GetTypeCharacter(), typeChar)
Dim type = Compilation.GetSpecialType(If(specialType = SpecialType.None, SpecialType.System_Object, specialType))
' NOTE: Don't create the local with the canonical name since we want it to have the user's text in diagnostic messages.
' TODO (acasey): don't canonicalize name (GH #878)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be best to expand "GH" for those reading the code long term. Also, no TODOs with aliases.

Dim canonicalName = Canonicalize(identifier.GetIdentifierText())
Dim local = LocalSymbol.Create(
_containingMethod,
Me,
identifier,
LocalDeclarationKind.ImplicitVariable,
type)
_implicitDeclarations.Add(Canonicalize(local.Name), local)
type,
canonicalName)
_implicitDeclarations.Add(canonicalName, local)
If local.Name.StartsWith("$", StringComparison.Ordinal) Then
diagnostics.Add(ERRID.ERR_IllegalChar, identifier.GetLocation())
End If
Expand Down Expand Up @@ -132,7 +134,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
End Select
End Function

Friend Shared Function Canonicalize(name As String) As String
Private Shared Function Canonicalize(name As String) As String
Return CaseInsensitiveComparison.ToLower(name)
End Function

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
' CreateVariable(type As Type, name As String)
Dim method = PlaceholderLocalSymbol.GetIntrinsicMethod(compilation, ExpressionCompilerConstants.CreateVariableMethodName)
Dim type = New BoundGetType(syntax, New BoundTypeExpression(syntax, local.Type), typeType)
Dim name = New BoundLiteral(syntax, ConstantValue.Create(PlaceholderLocalBinder.Canonicalize(local.Name)), stringType)
Dim name = New BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType)
Dim expr = New BoundCall(
syntax,
method,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ End Class"
// Code size 16 (0x10)
.maxstack 1
IL_0000: ldstr ""x""
IL_0005: call ""Function <>x.<>GetObjectByAlias(String) As Object""
IL_0005: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object""
IL_000a: castclass ""String""
IL_000f: ret
}
Expand Down Expand Up @@ -861,11 +861,11 @@ End Class"
IL_0000: ldtoken ""Object""
IL_0005: call ""Function System.Type.GetTypeFromHandle(System.RuntimeTypeHandle) As System.Type""
IL_000a: ldstr ""x""
IL_000f: call ""Sub <>x.<>CreateVariable(System.Type, String)""
IL_000f: call ""Sub Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.CreateVariable(System.Type, String)""
IL_0014: ldstr ""x""
IL_0019: call ""Function <>x.<>GetVariableAddress(Of Object)(String) As Object""
IL_0019: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress(Of Object)(String) As Object""
IL_001e: ldstr ""x""
IL_0023: call ""Function <>x.<>GetObjectByAlias(String) As Object""
IL_0023: call ""Function Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetObjectByAlias(String) As Object""
IL_0028: call ""Function System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(Object) As Object""
IL_002d: stind.ref
IL_002e: ret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ End Class"
expr:="$ReturnValue(Of Object)",
resultProperties:=resultProperties,
errorMessage:=errorMessage)
Assert.Equal("(1) : error BC32045: '$ReturnValue' has no type parameters and so cannot have type arguments.", errorMessage)
' TODO (acasey): don't canonicalize name (GH #878)
Assert.Equal("(1) : error BC32045: '$returnvalue' has no type parameters and so cannot have type arguments.", errorMessage)

Const source = "
Class C
Expand Down