Forráskód Böngészése

Emit compiler error on @:op(a = b) (closes #6903)

Aleksandr Kuzmenko 6 éve
szülő
commit
2341805c71

+ 2 - 0
src/typing/typeloadFields.ml

@@ -887,6 +887,8 @@ let check_abstract (ctx,cctx,fctx) c cf fd t ret p =
 					if fctx.is_macro then error (cf.cf_name ^ ": Macro array-access functions are not supported") p;
 					a.a_array <- cf :: a.a_array;
 					fctx.expr_presence_matters <- true;
+				| (Meta.Op,[EBinop(OpAssign,_,_),_],_) :: _ ->
+					error (cf.cf_name ^ ": Assignment overloading is not supported") p;
 				| (Meta.Op,[EBinop(op,_,_),_],_) :: _ ->
 					if fctx.is_macro then error (cf.cf_name ^ ": Macro operator functions are not supported") p;
 					let targ = if fctx.is_abstract_member then tthis else ta in

+ 9 - 0
tests/misc/projects/Issue6903/Main.hx

@@ -0,0 +1,9 @@
+class Main {
+	static function main() {}
+}
+
+abstract Test(Int) {
+	@:op(A = B) static function opAssign(a:Test, b:Test):Test {
+		return a;
+	}
+}

+ 1 - 0
tests/misc/projects/Issue6903/compile-fail.hxml

@@ -0,0 +1 @@
+-main Main

+ 1 - 0
tests/misc/projects/Issue6903/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:6: lines 6-8 : opAssign: Assignment overloading is not supported