Explorar o código

[macro] Compiler.include should not be called outside init macros

Rudy Ges hai 1 ano
pai
achega
3491304f34
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      std/haxe/macro/Compiler.hx

+ 3 - 0
std/haxe/macro/Compiler.hx

@@ -226,6 +226,8 @@ class Compiler {
 		If you want to specify a different set of paths to search for modules, you can use the optional
 		argument `classPath`.
 
+		Usage of this function outside of initialization macros is deprecated and may cause compilation server issues.
+
 		@param pack The package dot-path as String. Use `''` to include the root package.
 		@param rec If true, recursively adds all sub-packages.
 		@param ignore Array of module names to ignore for inclusion.
@@ -301,6 +303,7 @@ class Compiler {
 				Context.error('Package "$pack" was not found in any of class paths', Context.currentPos());
 		}
 
+		Context.assertInitMacro();
 		Context.onAfterInitMacros(() -> include(pack, rec, ignore, classPaths, strict));
 	}