Selaa lähdekoodia

[typer] fix global @:build on typedefs (#9781)

Dmitrii Maganov 5 vuotta sitten
vanhempi
commit
e0bb494b85
2 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 2 1
      src/typing/typeloadFields.ml
  2. 1 1
      src/typing/typeloadModule.ml

+ 2 - 1
src/typing/typeloadFields.ml

@@ -429,8 +429,9 @@ let apply_macro ctx mode path el p =
 	ctx.g.do_macro ctx mode cpath meth el p
 
 let build_module_def ctx mt meta fvars context_init fbuild =
+	let is_typedef = match mt with TTypeDecl _ -> true | _ -> false in
 	let loop f_build = function
-		| Meta.Build,args,p -> (fun () ->
+		| Meta.Build,args,p when not is_typedef -> (fun () ->
 				let epath, el = (match args with
 					| [ECall (epath,el),p] -> epath, el
 					| _ -> error "Invalid build parameters" p

+ 1 - 1
src/typing/typeloadModule.ml

@@ -840,7 +840,7 @@ let init_module_type ctx context_init (decl,p) =
 			| None -> Monomorph.bind r tt;
 			| Some _ -> die "" __LOC__);
 		| _ -> die "" __LOC__);
-		TypeloadFields.build_module_def ctx (TTypeDecl t) t.t_meta (fun _ -> []) context_init (fun _ -> error "@:build on typedef is not allowed" p);
+		TypeloadFields.build_module_def ctx (TTypeDecl t) t.t_meta (fun _ -> []) context_init (fun _ -> ());
 		if ctx.com.platform = Cs && t.t_meta <> [] then
 			delay ctx PTypeField (fun () ->
 				let metas = StrictMeta.check_strict_meta ctx t.t_meta in