Browse Source

fix assertion enum abstract values with casts (#8765)

Aleksandr Kuzmenko 6 years ago
parent
commit
0495c608df

+ 2 - 4
src/typing/typeloadFields.ml

@@ -797,10 +797,8 @@ let bind_var (ctx,cctx,fctx) cf e =
 					begin match c.cl_kind with
 						| KAbstractImpl a when Meta.has Meta.Enum cf.cf_meta && Meta.has Meta.Enum a.a_meta ->
 							unify ctx t (TAbstract(a,(List.map (fun _ -> mk_mono()) a.a_params))) p;
-							begin match e.eexpr with
-								| TCast(e1,None) -> unify ctx e1.etype a.a_this e1.epos
-								| _ -> assert false
-							end
+							let e1 = match e.eexpr with TCast(e1,None) -> e1 | _ -> e in
+							unify ctx e1.etype a.a_this e1.epos
 						| _ ->
 							()
 					end;

+ 7 - 0
tests/misc/projects/Issue8765/Main.hx

@@ -0,0 +1,7 @@
+class Main {
+	static function main() {}
+}
+
+enum abstract EA(String) {
+	var A = (null : EA);
+}

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

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

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

@@ -0,0 +1 @@
+Main.hx:6: characters 10-21 : EA should be String