Skip to content

Commit 0a2a991

Browse files
committed
parser: Show context-specific error message for Exit <compound>
1 parent 11995c6 commit 0a2a991

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Version 1.01.0
6565
- Literal zeroes with [U]Byte or [U]Short type (or the 16bit Integer in -lang qb) can now be passed to pointer parameters of overloaded procedures (now it's possible to call Bsave() with 0 source buffer in -lang qb again -- it also was affected by this bug since FB 0.90)
6666
- #760: RETURN and FUNCTION= couldn't be used together in byref functions returning an UDT with constructor. This check is now only applied to functions returning byval.
6767
- #755: If no result is set in byref functions, the compiler will now show an error instead of a warning (because a byref function defaults to returning a null reference, most likely causing a crash at runtime)
68-
- #754: Better error message for function result assignments outside of the function
68+
- Better error message for function result assignments outside of the function (#754), and for illegal use of Exit Sub|Function|...
6969

7070

7171
Version 1.00.0 (former 0.91.0):

src/compiler/parser-compound.bas

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ sub cExitStatement( )
188188
lexSkipToken( )
189189

190190
'' (FOR | DO | WHILE | SELECT | SUB | FUNCTION) (',')*
191-
select case as const lexGetToken( )
191+
var tk = lexGetToken( )
192+
select case as const( tk )
192193
case FB_TK_FOR
193194
if( parser.stmt.for = NULL ) then
194195
hExitError( FB_ERRMSG_ILLEGALOUTSIDEFORSTMT )
@@ -297,7 +298,16 @@ sub cExitStatement( )
297298
end if
298299

299300
if( label = NULL ) then
300-
hExitError( FB_ERRMSG_ILLEGALOUTSIDEAPROC )
301+
dim errmsg as integer
302+
select case as const( tk )
303+
case FB_TK_SUB : errmsg = FB_ERRMSG_ILLEGALOUTSIDEASUB
304+
case FB_TK_PROPERTY : errmsg = FB_ERRMSG_ILLEGALOUTSIDEANPROPERTY
305+
case FB_TK_OPERATOR : errmsg = FB_ERRMSG_ILLEGALOUTSIDEANOPERATOR
306+
case FB_TK_CONSTRUCTOR : errmsg = FB_ERRMSG_ILLEGALOUTSIDEACTOR
307+
case FB_TK_DESTRUCTOR : errmsg = FB_ERRMSG_ILLEGALOUTSIDEADTOR
308+
case else : errmsg = FB_ERRMSG_ILLEGALOUTSIDEAFUNCTION
309+
end select
310+
hExitError( errmsg )
301311
end if
302312

303313
dim as FB_ERRMSG errnum = FB_ERRMSG_OK

0 commit comments

Comments
 (0)