Explorar o código

Fixed internal error when ForEach is used with incompatible type

HurryStarfish %!s(int64=5) %!d(string=hai) anos
pai
achega
e5b1a3634a
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      parser.bmx

+ 4 - 3
parser.bmx

@@ -67,7 +67,8 @@ Type TForEachinStmt Extends TLoopStmt
 	End Method
 	End Method
 
 
 	Method OnSemant()
 	Method OnSemant()
-
+		Const NotIterableError:String = "EachIn requires a type that implements IIterable or has a suitable ObjectEnumerator method."
+		
 		expr=expr.Semant()
 		expr=expr.Semant()
 
 
 		If TArrayType( expr.exprType ) Or TStringType( expr.exprType )
 		If TArrayType( expr.exprType ) Or TStringType( expr.exprType )
@@ -195,7 +196,7 @@ Type TForEachinStmt Extends TLoopStmt
 			Else
 			Else
 				Local declList:TFuncDeclList = TFuncDeclList(TObjectType(expr.exprType).classDecl.GetDecl("objectenumerator"))
 				Local declList:TFuncDeclList = TFuncDeclList(TObjectType(expr.exprType).classDecl.GetDecl("objectenumerator"))
 				If Not declList Then
 				If Not declList Then
-					Err "Use of EachIn requires enumerable Type with either ObjectEnumerator method or one which implements IIterable interface."
+					Err NotIterableError
 				End If
 				End If
 			End If
 			End If
 
 
@@ -311,7 +312,7 @@ Type TForEachinStmt Extends TLoopStmt
 			End If
 			End If
 
 
 		Else
 		Else
-			InternalErr "TForEachinStmt.OnSemant"
+			Err NotIterableError
 		EndIf
 		EndIf
 
 
 		block.Semant
 		block.Semant