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

Merge branch 'development' into coroutines_2025

Simon Krajewski 1 éve
szülő
commit
92214ba39b

+ 5 - 10
src/compiler/args.ml

@@ -154,8 +154,7 @@ let parse_args com =
 			com.debug <- true;
 			com.debug <- true;
 		),"","add debug information to the compiled code");
 		),"","add debug information to the compiled code");
 		("Miscellaneous",["--version"],["-version"],Arg.Unit (fun() ->
 		("Miscellaneous",["--version"],["-version"],Arg.Unit (fun() ->
-			com.info s_version_full null_pos;
-			actx.did_something <- true;
+			raise (Helper.HelpMessage s_version_full);
 		),"","print version and exit");
 		),"","print version and exit");
 		("Miscellaneous", ["-h";"--help"], ["-help"], Arg.Unit (fun () ->
 		("Miscellaneous", ["-h";"--help"], ["-help"], Arg.Unit (fun () ->
 			raise (Arg.Help "")
 			raise (Arg.Help "")
@@ -163,31 +162,27 @@ let parse_args com =
 		("Miscellaneous",["--help-defines"],[], Arg.Unit (fun() ->
 		("Miscellaneous",["--help-defines"],[], Arg.Unit (fun() ->
 			let all,max_length = Define.get_documentation_list com.user_defines in
 			let all,max_length = Define.get_documentation_list com.user_defines in
 			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
 			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
-			List.iter (fun msg -> com.print (msg ^ "\n")) all;
-			actx.did_something <- true
+			raise (Helper.HelpMessage (ExtLib.String.join "\n" all));
 		),"","print help for all compiler specific defines");
 		),"","print help for all compiler specific defines");
 		("Miscellaneous",["--help-user-defines"],[], Arg.Unit (fun() ->
 		("Miscellaneous",["--help-user-defines"],[], Arg.Unit (fun() ->
 			actx.did_something <- true;
 			actx.did_something <- true;
 			com.callbacks#add_after_init_macros (fun() ->
 			com.callbacks#add_after_init_macros (fun() ->
 				let all,max_length = Define.get_user_documentation_list com.user_defines in
 				let all,max_length = Define.get_user_documentation_list com.user_defines in
 				let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
 				let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
-				List.iter (fun msg -> com.print (msg ^ "\n")) all;
-				raise Abort
+				raise (Helper.HelpMessage (ExtLib.String.join "\n" all));
 			)
 			)
 		),"","print help for all user defines");
 		),"","print help for all user defines");
 		("Miscellaneous",["--help-metas"],[], Arg.Unit (fun() ->
 		("Miscellaneous",["--help-metas"],[], Arg.Unit (fun() ->
 			let all,max_length = Meta.get_documentation_list com.user_metas in
 			let all,max_length = Meta.get_documentation_list com.user_metas in
 			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
 			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
-			List.iter (fun msg -> com.print (msg ^ "\n")) all;
-			actx.did_something <- true
+			raise (Helper.HelpMessage (ExtLib.String.join "\n" all));
 		),"","print help for all compiler metadatas");
 		),"","print help for all compiler metadatas");
 		("Miscellaneous",["--help-user-metas"],[], Arg.Unit (fun() ->
 		("Miscellaneous",["--help-user-metas"],[], Arg.Unit (fun() ->
 			actx.did_something <- true;
 			actx.did_something <- true;
 			com.callbacks#add_after_init_macros (fun() ->
 			com.callbacks#add_after_init_macros (fun() ->
 				let all,max_length = Meta.get_user_documentation_list com.user_metas in
 				let all,max_length = Meta.get_user_documentation_list com.user_metas in
 				let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
 				let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
-				List.iter (fun msg -> com.print (msg ^ "\n")) all;
-				raise Abort
+				raise (Helper.HelpMessage (ExtLib.String.join "\n" all));
 			)
 			)
 		),"","print help for all user metadatas");
 		),"","print help for all user metadatas");
 	] in
 	] in

+ 1 - 1
src/compiler/compiler.ml

@@ -440,7 +440,7 @@ with
 	| Failure msg when not Helper.is_debug_run ->
 	| Failure msg when not Helper.is_debug_run ->
 		error ctx ("Error: " ^ msg) null_pos
 		error ctx ("Error: " ^ msg) null_pos
 	| Helper.HelpMessage msg ->
 	| Helper.HelpMessage msg ->
-		com.info msg null_pos
+		print_endline msg
 	| Parser.TypePath (p,c,is_import,pos) ->
 	| Parser.TypePath (p,c,is_import,pos) ->
 		DisplayOutput.handle_type_path_exception ctx p c is_import pos
 		DisplayOutput.handle_type_path_exception ctx p c is_import pos
 	| Parser.SyntaxCompletion(kind,subj) ->
 	| Parser.SyntaxCompletion(kind,subj) ->

+ 0 - 1
src/compiler/hxb/hxbWriter.ml

@@ -1067,7 +1067,6 @@ module HxbWriter = struct
 		with Not_found ->
 		with Not_found ->
 			let restore = start_temporary_chunk writer 256 in
 			let restore = start_temporary_chunk writer 256 in
 			let old = writer.wrote_local_type_param in
 			let old = writer.wrote_local_type_param in
-			writer.wrote_local_type_param <- false;
 			ignore(write_class_field_and_overloads_data writer true cf);
 			ignore(write_class_field_and_overloads_data writer true cf);
 			let wrote_local_type_param = writer.wrote_local_type_param in
 			let wrote_local_type_param = writer.wrote_local_type_param in
 			writer.wrote_local_type_param <- old;
 			writer.wrote_local_type_param <- old;

+ 3 - 1
src/compiler/server.ml

@@ -399,7 +399,9 @@ class hxb_reader_api_server
 			m_path = path;
 			m_path = path;
 			m_types = [];
 			m_types = [];
 			m_statics = None;
 			m_statics = None;
-			m_extra = mc.mc_extra
+			(* Creating a new m_extra because if we keep the same reference, display requests *)
+			(* can alter it with bad data (for example adding dependencies that are not cached) *)
+			m_extra = { mc.mc_extra with m_deps = mc.mc_extra.m_deps }
 		}
 		}
 
 
 	method add_module (m : module_def) =
 	method add_module (m : module_def) =

+ 2 - 0
src/context/common.ml

@@ -826,6 +826,7 @@ let create compilation_step cs version args display_mode =
 		pass_debug_messages = DynArray.create();
 		pass_debug_messages = DynArray.create();
 		basic = {
 		basic = {
 			tvoid = mk_mono();
 			tvoid = mk_mono();
+			tany = mk_mono();
 			tint = mk_mono();
 			tint = mk_mono();
 			tfloat = mk_mono();
 			tfloat = mk_mono();
 			tbool = mk_mono();
 			tbool = mk_mono();
@@ -875,6 +876,7 @@ let clone com is_macro_context =
 		cache = None;
 		cache = None;
 		basic = { t with
 		basic = { t with
 			tvoid = mk_mono();
 			tvoid = mk_mono();
+			tany = mk_mono();
 			tint = mk_mono();
 			tint = mk_mono();
 			tfloat = mk_mono();
 			tfloat = mk_mono();
 			tbool = mk_mono();
 			tbool = mk_mono();

+ 3 - 1
src/context/display/displayJson.ml

@@ -116,7 +116,9 @@ class hxb_reader_api_com
 			m_path = path;
 			m_path = path;
 			m_types = [];
 			m_types = [];
 			m_statics = None;
 			m_statics = None;
-			m_extra = mc.mc_extra
+			(* Creating a new m_extra because if we keep the same reference, display requests *)
+			(* can alter it with bad data (for example adding dependencies that are not cached) *)
+			m_extra = { mc.mc_extra with m_deps = mc.mc_extra.m_deps }
 		}
 		}
 
 
 	method add_module (m : module_def) =
 	method add_module (m : module_def) =

+ 1 - 0
src/core/tType.ml

@@ -454,6 +454,7 @@ exception Type_exception of t
 
 
 type basic_types = {
 type basic_types = {
 	mutable tvoid : t;
 	mutable tvoid : t;
+	mutable tany : t;
 	mutable tint : t;
 	mutable tint : t;
 	mutable tfloat : t;
 	mutable tfloat : t;
 	mutable tbool : t;
 	mutable tbool : t;

+ 4 - 4
src/filters/filters.ml

@@ -507,7 +507,7 @@ let destruction tctx detail_times main locals =
 	com.callbacks#run com.error_ext com.callbacks#get_after_filters;
 	com.callbacks#run com.error_ext com.callbacks#get_after_filters;
 	enter_stage com CFilteringDone
 	enter_stage com CFilteringDone
 
 
-let update_cache_dependencies com t =
+let update_cache_dependencies ~close_monomorphs com t =
 	let visited_anons = ref [] in
 	let visited_anons = ref [] in
 	let rec check_t m t = match t with
 	let rec check_t m t = match t with
 		| TInst(c,tl) ->
 		| TInst(c,tl) ->
@@ -535,8 +535,8 @@ let update_cache_dependencies com t =
 				| Some t ->
 				| Some t ->
 					check_t m t
 					check_t m t
 				| _ ->
 				| _ ->
-					(* Bind any still open monomorph that's part of a signature to Dynamic now (issue #10653) *)
-					Monomorph.do_bind r t_dynamic;
+					(* Bind any still open monomorph that's part of a signature to Any now (issue #10653) *)
+					if close_monomorphs then Monomorph.do_bind r com.basic.tany;
 		end
 		end
 		| TLazy f ->
 		| TLazy f ->
 			check_t m (lazy_type f)
 			check_t m (lazy_type f)
@@ -742,7 +742,7 @@ let run tctx main before_destruction =
 	enter_stage com CSaveStart;
 	enter_stage com CSaveStart;
 	with_timer detail_times "save state" None (fun () ->
 	with_timer detail_times "save state" None (fun () ->
 		List.iter (fun mt ->
 		List.iter (fun mt ->
-			update_cache_dependencies com mt;
+			update_cache_dependencies ~close_monomorphs:true com mt;
 			save_class_state com mt
 			save_class_state com mt
 		) new_types;
 		) new_types;
 	);
 	);

+ 0 - 5
src/generators/genjvm.ml

@@ -2777,11 +2777,6 @@ let generate_enum_equals gctx (jc_ctor : JvmClass.builder) =
 		else
 		else
 			compare_standard jsig
 			compare_standard jsig
 	in
 	in
-	load();
-	jm_equals#invokevirtual java_enum_path "ordinal" (method_sig [] (Some TInt));
-	jm_equals#load_this;
-	jm_equals#invokevirtual java_enum_path "ordinal" (method_sig [] (Some TInt));
-	compare TInt;
 	let compare_field n jsig =
 	let compare_field n jsig =
 		load();
 		load();
 		jm_equals#getfield jc_ctor#get_this_path n jsig;
 		jm_equals#getfield jc_ctor#get_this_path n jsig;

+ 1 - 0
src/typing/macroContext.ml

@@ -636,6 +636,7 @@ and flush_macro_context mint mctx =
 		FiltersCommon.remove_generic_base;
 		FiltersCommon.remove_generic_base;
 		Exceptions.patch_constructors mctx;
 		Exceptions.patch_constructors mctx;
 		(fun mt -> AddFieldInits.add_field_inits mctx.c.curclass.cl_path (RenameVars.init mctx.com) mctx.com mt);
 		(fun mt -> AddFieldInits.add_field_inits mctx.c.curclass.cl_path (RenameVars.init mctx.com) mctx.com mt);
+		Filters.update_cache_dependencies ~close_monomorphs:false mctx.com;
 		minimal_restore;
 		minimal_restore;
 	] in
 	] in
 	let ready = fun t ->
 	let ready = fun t ->

+ 11 - 0
src/typing/typerEntry.ml

@@ -127,6 +127,17 @@ let create com macros =
 		| TClassDecl ({cl_path = ([],"Std")} as c) -> ctx.com.std <- c;
 		| TClassDecl ({cl_path = ([],"Std")} as c) -> ctx.com.std <- c;
 		| _ -> ()
 		| _ -> ()
 	) m.m_types;
 	) m.m_types;
+	let m = TypeloadModule.load_module ctx ([],"Any") null_pos in
+	List.iter (fun mt -> match mt with
+		| TAbstractDecl a ->
+			(match snd a.a_path with
+			| "Any" ->
+				let t = TAbstract (a,[]) in
+				Type.unify t ctx.t.tany;
+				ctx.t.tany <- t;
+			| _ -> ())
+		| _ -> ()
+	) m.m_types;
 	let m = TypeloadModule.load_module ctx ([],"Array") null_pos in
 	let m = TypeloadModule.load_module ctx ([],"Array") null_pos in
 	(try
 	(try
 		List.iter (fun t -> (
 		List.iter (fun t -> (

+ 1 - 0
tests/misc/projects/Issue8471/Macro.hx

@@ -2,6 +2,7 @@ import haxe.macro.Context;
 
 
 class Macro {
 class Macro {
 	public static function init() {
 	public static function init() {
+		Context.info("Info", Context.currentPos());
 		Context.warning("This warning will disappear", Context.currentPos());
 		Context.warning("This warning will disappear", Context.currentPos());
 
 
 		Context.onAfterTyping(afterTyping);
 		Context.onAfterTyping(afterTyping);

+ 1 - 0
tests/misc/projects/Issue8471/Macro2.hx

@@ -9,6 +9,7 @@ class Macro2 {
 	}
 	}
 
 
 	static function afterTyping(_) {
 	static function afterTyping(_) {
+		Context.info("Info", Context.currentPos());
 		Context.warning(("1" :DeprecatedType), Context.currentPos());
 		Context.warning(("1" :DeprecatedType), Context.currentPos());
 		Context.warning("2", Context.currentPos());
 		Context.warning("2", Context.currentPos());
 		Context.warning("3", Context.currentPos());
 		Context.warning("3", Context.currentPos());

+ 0 - 1
tests/misc/projects/Issue8471/compile.hxml

@@ -1,2 +1 @@
---version
 --macro Macro.init()
 --macro Macro.init()

+ 2 - 2
tests/misc/projects/Issue8471/compile2-pretty.hxml.stderr

@@ -1,6 +1,6 @@
-[WARNING] (macro) Macro2.hx:12: characters 25-39
+[WARNING] (macro) Macro2.hx:13: characters 25-39
 
 
- 12 |   Context.warning(("1" :DeprecatedType), Context.currentPos());
+ 13 |   Context.warning(("1" :DeprecatedType), Context.currentPos());
     |                         ^^^^^^^^^^^^^^
     |                         ^^^^^^^^^^^^^^
     | (WDeprecated) This typedef is deprecated in favor of String
     | (WDeprecated) This typedef is deprecated in favor of String
 
 

+ 0 - 1
tests/misc/projects/Issue8471/compile2.hxml

@@ -1,2 +1 @@
---version
 --macro Macro2.init()
 --macro Macro2.init()

+ 1 - 1
tests/misc/projects/Issue8471/compile2.hxml.stderr

@@ -1,4 +1,4 @@
-Macro2.hx:12: characters 25-39 : Warning : (WDeprecated) This typedef is deprecated in favor of String
+Macro2.hx:13: characters 25-39 : Warning : (WDeprecated) This typedef is deprecated in favor of String
 Warning : 1
 Warning : 1
 Warning : 2
 Warning : 2
 Warning : 3
 Warning : 3

+ 22 - 0
tests/server/src/cases/issues/Issue10653.hx

@@ -1,5 +1,7 @@
 package cases.issues;
 package cases.issues;
 
 
+import haxe.display.Diagnostic;
+
 class Issue10653 extends TestCase {
 class Issue10653 extends TestCase {
 	function test(_) {
 	function test(_) {
 		vfs.putContent("Test.hx", getTemplate("issues/Issue10653/Test.hx"));
 		vfs.putContent("Test.hx", getTemplate("issues/Issue10653/Test.hx"));
@@ -16,4 +18,24 @@ class Issue10653 extends TestCase {
 			Assert.equals(0, res.length);
 			Assert.equals(0, res.length);
 		});
 		});
 	}
 	}
+
+	function testTypeHole(_) {
+		vfs.putContent("Test.hx", getTemplate("issues/Issue10653/Test.hx"));
+		vfs.putContent("Main.hx", getTemplate("issues/Issue10653/MainBefore.hx"));
+		var args = ["-main", "Main", "--js", "no.js", "--no-output"];
+		runHaxe(args);
+		vfs.putContent("Main.hx", getTemplate("issues/Issue10653/MainAfterWrong.hx"));
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Main.hx")}, res -> {
+			Assert.equals(1, res.length);
+			var arg:MissingFieldDiagnostics = cast res[0].diagnostics[0].args;
+			Assert.equals("foo", arg.entries[0].fields[0].field.name);
+		});
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Main.hx")}, res -> {
+			Assert.equals(1, res.length);
+			var arg:MissingFieldDiagnostics = cast res[0].diagnostics[0].args;
+			Assert.equals("foo", arg.entries[0].fields[0].field.name);
+		});
+	}
 }
 }

+ 9 - 0
tests/server/test/templates/issues/Issue10653/MainAfterWrong.hx

@@ -0,0 +1,9 @@
+class Main {
+	static function main() {
+		var x = Test.test();
+		x = new Main();
+		x.foo = "wtf";
+	}
+
+	function new() {}
+}