瀏覽代碼

Structs can only be compared using an appropriate overload. Fixes #434.

woollybah 6 年之前
父節點
當前提交
b8dd2396b2
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      expr.bmx

+ 5 - 1
expr.bmx

@@ -2015,7 +2015,11 @@ Type TBinaryCompareExpr Extends TBinaryExpr
 					Return New TInvokeMemberExpr.Create( lhs, decl, args ).Semant()
 					Return New TInvokeMemberExpr.Create( lhs, decl, args ).Semant()
 				End If
 				End If
 			Catch error:String
 			Catch error:String
-				' no overload, continue...
+				' Structs must define an operator overload for the given op
+				If TObjectType(lhs.exprType).classDecl.IsStruct() Then
+					Err "No overloaded operator '" + op + "' found for " + TObjectType(lhs.exprType).classDecl.ToString()
+				End If
+				' otherwise, no overload, continue...
 			End Try
 			End Try
 		End If
 		End If