浏览代码

Merge pull request #483 from HurryStarfish/patch-4

Fixed internal error when ForEach is used with incompatible type
Brucey 5 年之前
父节点
当前提交
6a6897c522
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      parser.bmx

+ 4 - 3
parser.bmx

@@ -67,7 +67,8 @@ Type TForEachinStmt Extends TLoopStmt
 	End Method
 
 	Method OnSemant()
-
+		Const NotIterableError:String = "EachIn requires a type that implements IIterable or has a suitable ObjectEnumerator method."
+		
 		expr=expr.Semant()
 
 		If TArrayType( expr.exprType ) Or TStringType( expr.exprType )
@@ -195,7 +196,7 @@ Type TForEachinStmt Extends TLoopStmt
 			Else
 				Local declList:TFuncDeclList = TFuncDeclList(TObjectType(expr.exprType).classDecl.GetDecl("objectenumerator"))
 				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
 
@@ -311,7 +312,7 @@ Type TForEachinStmt Extends TLoopStmt
 			End If
 
 		Else
-			InternalErr "TForEachinStmt.OnSemant"
+			Err NotIterableError
 		EndIf
 
 		block.Semant