Permalink
Browse files

Make the error message and reported location for error BC30099 consis…

…tent with VBC.
  • Loading branch information...
lee-m committed Sep 18, 2011
1 parent b4c1be5 commit 0089fde407ec3333b0bb2218f63fa907fea4cce0
@@ -674,7 +674,7 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC30098 = 30098
''' <summary>
- ''' VBNC = "This 'Exit Select' statement is not contained within a 'Select' statement."
+ ''' VBNC = "'Exit Select' can only appear inside a 'Select' statement."
''' VB = "'Exit Select' can only appear inside a 'Select' statement."
''' </summary>
''' <remarks></remarks>
@@ -5173,17 +5173,19 @@ Public Class Parser
''' <remarks></remarks>
Private Function ParseExitStatement(ByVal Parent As ParsedObject) As ExitStatement
Dim m_ExitWhat As KS
+ Dim exitLocation As Span
tm.AcceptIfNotInternalError(KS.Exit)
If tm.CurrentToken.Equals(KS.Sub, KS.Function, KS.Property, KS.Do, KS.For, KS.Try, KS.While, KS.Select) Then
m_ExitWhat = tm.CurrentToken.Keyword
+ exitLocation = tm.CurrentLocation
tm.NextToken()
Else
Compiler.Report.ShowMessage(Messages.VBNC30240, tm.CurrentLocation)
Return Nothing
End If
- Return New ExitStatement(Parent, m_ExitWhat)
+ Return New ExitStatement(Parent, m_ExitWhat, exitLocation)
End Function
''' <summary>
@@ -404,7 +404,7 @@
<value>CHANGEME</value>
</data>
<data name="30099" xml:space="preserve">
- <value>This 'Exit Select' statement is not contained within a 'Select' statement.</value>
+ <value>'Exit Select' can only appear inside a 'Select' statement.</value>
</data>
<data name="30101" xml:space="preserve">
<value>CHANGEME</value>
@@ -474,7 +474,7 @@
</Message>
<Message id="30099" level="Error">
<Comment>NC</Comment>
- <VBNCValue>This 'Exit Select' statement is not contained within a 'Select' statement.</VBNCValue>
+ <VBNCValue>'Exit Select' can only appear inside a 'Select' statement.</VBNCValue>
<VBValue>'Exit Select' can only appear inside a 'Select' statement.</VBValue>
</Message>
<Message id="30101" level="Error">
@@ -38,6 +38,11 @@ Public Class ExitStatement
m_ExitWhat = ExitWhat
End Sub
+ Sub New(ByVal Parent As ParsedObject, ByVal ExitWhat As KS, Location As Span)
+ MyBase.New(Parent, Location)
+ m_ExitWhat = ExitWhat
+ End Sub
+
Friend Overrides Function GenerateCode(ByVal Info As EmitInfo) As Boolean
Dim result As Boolean = True
@@ -36,6 +36,10 @@ Public MustInherit Class Statement
MyBase.New(Parent)
End Sub
+ Sub New(ByVal Parent As ParsedObject, Location As Span)
+ MyBase.New(Parent, Location)
+ End Sub
+
ReadOnly Property FindParentCodeBlock() As CodeBlock
Get
Return MyBase.FindFirstParent(Of CodeBlock)()
@@ -0,0 +1,11 @@
+Module Main
+
+ Sub Foo
+
+ If True Then
+ Exit Select
+ End If
+
+ End Sub
+
+End Module
@@ -24285,4 +24285,8 @@
<file>Errors\30106.vb</file>
<error line="6" number="30106" message="Number of indices exceeds the number of dimensions of the indexed array." />
</test>
+ <test id="3148" name="30099" expectedexitcode="1" mytype="empty">
+ <file>Errors\30099.vb</file>
+ <error line="6" number="30099" message="'Exit Select' can only appear inside a 'Select' statement." />
+ </test>
</rt>

0 comments on commit 0089fde

Please sign in to comment.