Browse Source

Merge pull request #398 from HurryStarfish/patch-2

"Select Null" no longer causes internal error. Fixes #397.
Brucey 6 years ago
parent
commit
5d46bcd148
1 changed files with 14 additions and 6 deletions
  1. 14 6
      parser.bmx

+ 14 - 6
parser.bmx

@@ -2110,11 +2110,14 @@ End Rem
 		Parse "select"
 
 		Local block:TBlockDecl=_block
-
-		Local tmpVar:TLocalDecl=New TLocalDecl.Create( "",Null,ParseExpr(),,True )
-
-		block.AddStmt New TDeclStmt.Create( tmpVar )
-
+		
+		Local tmpVar:TLocalDecl
+		Local selectExpr:TExpr = ParseExpr()
+		If Not TNullType(selectExpr.exprType)
+			tmpVar = New TLocalDecl.Create("", Null, selectExpr, , True)
+			block.AddStmt New TDeclStmt.Create(tmpVar)
+		End If
+		
 		While _toke<>"end" And _toke<>"default" And _toke<>"endselect"
 			SetErr
 			Select _toke
@@ -2124,7 +2127,12 @@ End Rem
 				NextToke
 				Local comp:TExpr
 				Repeat
-					Local expr:TExpr=New TVarExpr.Create( tmpVar )
+					Local expr:TExpr
+					If TNullType(selectExpr.exprType)
+						expr = New TNullExpr.Create(TType.nullObjectType)
+					Else
+						expr = New TVarExpr.Create(tmpVar)
+					End If
 					expr=New TBinaryCompareExpr.Create( "=",expr,ParseExpr() )
 					If comp
 						comp=New TBinaryLogicExpr.Create( "or",comp,expr )