Browse Source

Improved error message for Eachin use. Fixes #356.

woollybah 6 years ago
parent
commit
b8ec703996
1 changed files with 5 additions and 0 deletions
  1. 5 0
      parser.bmx

+ 5 - 0
parser.bmx

@@ -183,6 +183,11 @@ Type TForEachinStmt Extends TLoopStmt
 			
 			
 			If TObjectType(expr.exprType).classDecl.ImplementsInterface("iiterable") Then
 			If TObjectType(expr.exprType).classDecl.ImplementsInterface("iiterable") Then
 				iterable = True
 				iterable = True
+			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."
+				End If
 			End If
 			End If
 
 
 			If TInvokeExpr(expr) Or TInvokeMemberExpr(expr) Then
 			If TInvokeExpr(expr) Or TInvokeMemberExpr(expr) Then