Skip to content

Commit 0089fde

Browse files
committed
Make the error message and reported location for error BC30099 consistent with VBC.
1 parent b4c1be5 commit 0089fde

File tree

8 files changed

+30
-4
lines changed

8 files changed

+30
-4
lines changed

vbnc/vbnc/source/General/Messages.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ Public Enum Messages
674674
<Message(MessageLevel.Error)> VBNC30098 = 30098
675675

676676
''' <summary>
677-
''' VBNC = "This 'Exit Select' statement is not contained within a 'Select' statement."
677+
''' VBNC = "'Exit Select' can only appear inside a 'Select' statement."
678678
''' VB = "'Exit Select' can only appear inside a 'Select' statement."
679679
''' </summary>
680680
''' <remarks></remarks>

vbnc/vbnc/source/Parser/Parser.vb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5173,17 +5173,19 @@ Public Class Parser
51735173
''' <remarks></remarks>
51745174
Private Function ParseExitStatement(ByVal Parent As ParsedObject) As ExitStatement
51755175
Dim m_ExitWhat As KS
5176+
Dim exitLocation As Span
51765177

51775178
tm.AcceptIfNotInternalError(KS.Exit)
51785179
If tm.CurrentToken.Equals(KS.Sub, KS.Function, KS.Property, KS.Do, KS.For, KS.Try, KS.While, KS.Select) Then
51795180
m_ExitWhat = tm.CurrentToken.Keyword
5181+
exitLocation = tm.CurrentLocation
51805182
tm.NextToken()
51815183
Else
51825184
Compiler.Report.ShowMessage(Messages.VBNC30240, tm.CurrentLocation)
51835185
Return Nothing
51845186
End If
51855187

5186-
Return New ExitStatement(Parent, m_ExitWhat)
5188+
Return New ExitStatement(Parent, m_ExitWhat, exitLocation)
51875189
End Function
51885190

51895191
''' <summary>

vbnc/vbnc/source/Resources/Errors.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404
<value>CHANGEME</value>
405405
</data>
406406
<data name="30099" xml:space="preserve">
407-
<value>This 'Exit Select' statement is not contained within a 'Select' statement.</value>
407+
<value>'Exit Select' can only appear inside a 'Select' statement.</value>
408408
</data>
409409
<data name="30101" xml:space="preserve">
410410
<value>CHANGEME</value>

vbnc/vbnc/source/Resources/Source.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
</Message>
475475
<Message id="30099" level="Error">
476476
<Comment>NC</Comment>
477-
<VBNCValue>This 'Exit Select' statement is not contained within a 'Select' statement.</VBNCValue>
477+
<VBNCValue>'Exit Select' can only appear inside a 'Select' statement.</VBNCValue>
478478
<VBValue>'Exit Select' can only appear inside a 'Select' statement.</VBValue>
479479
</Message>
480480
<Message id="30101" level="Error">

vbnc/vbnc/source/Statements/ExitStatement.vb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Public Class ExitStatement
3838
m_ExitWhat = ExitWhat
3939
End Sub
4040

41+
Sub New(ByVal Parent As ParsedObject, ByVal ExitWhat As KS, Location As Span)
42+
MyBase.New(Parent, Location)
43+
m_ExitWhat = ExitWhat
44+
End Sub
45+
4146
Friend Overrides Function GenerateCode(ByVal Info As EmitInfo) As Boolean
4247
Dim result As Boolean = True
4348

vbnc/vbnc/source/Statements/Statement.vb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Public MustInherit Class Statement
3636
MyBase.New(Parent)
3737
End Sub
3838

39+
Sub New(ByVal Parent As ParsedObject, Location As Span)
40+
MyBase.New(Parent, Location)
41+
End Sub
42+
3943
ReadOnly Property FindParentCodeBlock() As CodeBlock
4044
Get
4145
Return MyBase.FindFirstParent(Of CodeBlock)()

vbnc/vbnc/tests/Errors/30099.vb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Module Main
2+
3+
Sub Foo
4+
5+
If True Then
6+
Exit Select
7+
End If
8+
9+
End Sub
10+
11+
End Module

vbnc/vbnc/tests/tests.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24285,4 +24285,8 @@
2428524285
<file>Errors\30106.vb</file>
2428624286
<error line="6" number="30106" message="Number of indices exceeds the number of dimensions of the indexed array." />
2428724287
</test>
24288+
<test id="3148" name="30099" expectedexitcode="1" mytype="empty">
24289+
<file>Errors\30099.vb</file>
24290+
<error line="6" number="30099" message="'Exit Select' can only appear inside a 'Select' statement." />
24291+
</test>
2428824292
</rt>

0 commit comments

Comments
 (0)