-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[macro] Detect some invalid usages of the haxe.macro.Compiler API #7871
Comments
If we can address the "Another problem", we could further improve the compilation server by not initializing the outside context before running initialization macros. At the moment, we add a bunch of modules immediately when creating the typer: StdTypes, String, Array, haxe.EnumTools. If an initialization macro adds a define, these types will forever remain unused on the compilation server. Ideally, we would do this:
The one place I can think of where we need types is when typing constant macro arguments. However, we should be able to simply do this in the macro context instead of the outside context. In vshaxe, we have 4 |
How about we add a value to the |
Being able to type arbitrary things at init macro is nice if one wants to configure something based on the code in project. So how about another approach:
Compilation flow would look like this: |
Note that the problem isn't the macro context, it's the compilation context. |
We have so many contexts in the code, I just mix them together :) |
And yes, methods changing compilation configuration should only be available in init macros. |
Any time previsions for this one? The 'redefined' problem is a bit of a pain in the ass :( |
At the moment, the
haxe.macro.Compiler
API has various functions that modify compilation parameters. However, they can be freely used from any random macro, which I don't think was the original intent.For instance, using
Compiler.addClassPath
in the middle of a compilation could lead to very weird situations where some parts of a package are resolved in one class path and other parts are resolved in another class path. This coupled with the undefined build order is almost certainly not what anyone wants.In similar fashion, using
Compiler.define
at some random point in time causes a hot mess in the compilation server because suddenly the define hash changed.I think we should restrict these operations to initialization macros. However, I don't know how to transition this properly.
Another problem
is that the
haxe.macro.Compiler
API itself can cause typing. For instance,include
usesContext.getModule
. This is pretty bad because we never reach a proper "configuration done" state due to this.Ideally, we would have a properly defined order:
haxe.macro.Compiler
which modifies compilation parameters.Any thoughts?
The text was updated successfully, but these errors were encountered: