Skip to content

Commit 5d96a10

Browse files
committed
Change the error issed for array modifiers appearing on both the type and variable name to match the behavior of VBC.
1 parent f78cf92 commit 5d96a10

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

vbnc/vbnc/source/General/Messages.vb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4643,7 +4643,7 @@ Public Enum Messages
46434643
<Message(MessageLevel.Error)> VBNC31086 = 31086
46444644

46454645
''' <summary>
4646-
''' VBNC = "A variable can't declare array modifiers both on the variable name and on the type."
4646+
''' VBNC = "Array modifiers cannot be specified on both a variable and its type."
46474647
''' VB = "Array modifiers cannot be specified on both a variable and its type."
46484648
''' </summary>
46494649
''' <remarks></remarks>
@@ -6946,4 +6946,3 @@ Public Enum Messages
69466946
<Message(MessageLevel.Error)> VBNC99999 = 99999
69476947

69486948
End Enum
6949-

vbnc/vbnc/source/Members/VariableDeclaration.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Public MustInherit Class VariableDeclaration
175175

176176
If m_VariableIdentifier IsNot Nothing AndAlso m_VariableIdentifier.HasArrayNameModifier Then
177177
If CecilHelper.IsArray(m_VariableType) Then
178-
result = Helper.AddError(Me, "Cannot specify array modifier on both type name and on variable name.") AndAlso result
178+
result = Compiler.Report.ShowMessage(Messages.VBNC31087, Location) AndAlso result
179179
Else
180180
If m_VariableIdentifier.ArrayNameModifier.IsArraySizeInitializationModifier Then
181181
m_VariableType = m_VariableIdentifier.ArrayNameModifier.AsArraySizeInitializationModifier.CreateArrayType(m_VariableType)

vbnc/vbnc/source/Resources/Errors.resx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -112,10 +112,10 @@
112112
<value>2.0</value>
113113
</resheader>
114114
<resheader name="reader">
115-
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116116
</resheader>
117117
<resheader name="writer">
118-
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="warning" xml:space="preserve">
121121
<value>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -2105,7 +2105,7 @@
21052105
<value>CHANGEME</value>
21062106
</data>
21072107
<data name="31087" xml:space="preserve">
2108-
<value>A variable can't declare array modifiers both on the variable name and on the type.</value>
2108+
<value>Array modifiers cannot be specified on both a variable and its type.</value>
21092109
</data>
21102110
<data name="31088" xml:space="preserve">
21112111
<value>CHANGEME</value>
@@ -3091,5 +3091,4 @@
30913091
<data name="99999" xml:space="preserve">
30923092
<value>{0}</value>
30933093
</data>
3094-
</root>
3095-
3094+
</root>

vbnc/vbnc/source/Resources/Source.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3309,7 +3309,7 @@
33093309
</Message>
33103310
<Message id="31087" level="Error">
33113311
<Comment>NC</Comment>
3312-
<VBNCValue>A variable can't declare array modifiers both on the variable name and on the type.</VBNCValue>
3312+
<VBNCValue>Array modifiers cannot be specified on both a variable and its type.</VBNCValue>
33133313
<VBValue>Array modifiers cannot be specified on both a variable and its type.</VBValue>
33143314
</Message>
33153315
<Message id="31088" level="Error">

vbnc/vbnc/tests/Errors/31087.vb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Module Test
2+
3+
Sub Foo()
4+
5+
Dim a() As String()
6+
7+
End Sub
8+
9+
End Module

vbnc/vbnc/tests/tests.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24247,4 +24247,9 @@
2424724247
<file>Errors\30057-2.vb</file>
2424824248
<error line="11" number="30057" message="Too many arguments to 'Public Sub Z()'." />
2424924249
</test>
24250+
<test id="3133" name="31087" expectedexitcode="1" expectedvbcexitcode="1" mytype="empty">
24251+
<file>Errors\31087.vb</file>
24252+
<error line="5" number="31087" message="Array modifiers cannot be specified on both a variable and its type." />
24253+
<vbcerror line="5" number="31087" message="Array modifiers cannot be specified on both a variable and its type." />
24254+
</test>
2425024255
</rt>

0 commit comments

Comments
 (0)