Skip to content

Commit 11995c6

Browse files
committed
parser: Add better error message for result assignment outside function
1 parent be20f5b commit 11995c6

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +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
6869

6970

7071
Version 1.00.0 (former 0.91.0):

src/compiler/error.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ declare function hMakeParamDesc _
396396
@"the first parameter in a procedure may not be vararg", _
397397
@"CONST used on constructor (not needed)", _
398398
@"CONST used on destructor (not needed)", _
399-
@"Byref function result not set" _
399+
@"Byref function result not set", _
400+
@"Function result assignment outside of the function" _
400401
}
401402

402403

src/compiler/error.bi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ enum FB_ERRMSG
318318
FB_ERRMSG_CONSTCTOR
319319
FB_ERRMSG_CONSTDTOR
320320
FB_ERRMSG_NOBYREFFUNCTIONRESULT
321+
FB_ERRMSG_RESULTASSIGNOUTSIDEFUNCTION
321322

322323
FB_ERRMSGS
323324
end enum

src/compiler/parser-proccall.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ private function hProcSymbol _
449449

450450
'' check if name is valid (or if overloaded)
451451
if( symbIsProcOverloadOf( parser.currproc, sym ) = FALSE ) then
452-
errReport( FB_ERRMSG_ILLEGALOUTSIDEAPROC )
452+
errReport( FB_ERRMSG_RESULTASSIGNOUTSIDEFUNCTION )
453453
'' error recovery: skip stmt, return
454454
hSkipStmt( )
455455
return TRUE

0 commit comments

Comments
 (0)