-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
pack.NonMainModuleClass
access works when module is imported
#9150
Comments
Note that even if we deem this a bug, I don't think we should break it in a dot release. It doesn't do any harm because there can only be at most one |
I don't see any value in changing this. |
Well, it's surely minor, but IMO the relation between packages, modules and types in our system is confusing enough already and this inconsistency is not helping. |
This could "break" some macros that don't handle correctly name + sub but currently work because of pack.A resolution. Not a big deal but this may indeed not be worth breaking/fixing in a dot release. |
Well, arguably, these macros are already broken since they depend on whether the module is imported at the usage place or not. And IMO this fact favors fixing this, because then people will write proper macros :) |
So I understand this correctly, there are two cases:
? (Also given the fact that Haxe affords me the shorthand to specify class names like "pack.Module" instead of the more strictly accurate "pack.Module.Module" for a class Module in module pack/Module.hx.) As it stands now (with Haxe v4.0.5), given pack/Module.hx: package pack;
class Module {}
class A {} Case 1: when you don't do the import: in Main.hx: //import pack.Module;
class Main {
public static function main() {
trace(pack.Module.Module);
trace(pack.Module); // The allowed shorthand.
//trace(Module); //<--- ERROR
trace(pack.Module.A);
//trace(pack.A); //<--- ERROR
//trace(Module.A); //<--- ERROR
//trace(A); //<--- ERROR
}
} Seems straightforward and reasonable. Case 2: when you do do the import: import pack.Module;
class Main {
public static function main() {
trace(pack.Module.Module);
trace(pack.Module); // The allowed shorthand.
trace(Module); // Even shorter shorthand.
trace(pack.Module.A);
trace(pack.A); // (1)
//trace(Module.A); //<--- ERROR
trace(A); // (2)
}
} So, the only thing up for consideration here is removing the one marked The one marked Is there a strict mode that would disallow |
It's about removing
|
Thanks, Dan. Ah, I see. The way Yes, being warned if shadowing were to happen seems useful to me. Though, with programming languages I generally tend to want safety nets over the wild west anyway. :) But my issue with |
I (accidentally) broke this while working on #11168 and took the opportunity to log problems that come from it:
So in the grand scheme of things, disallowing this kind of resolution should be rather harmless. |
Actually the AsyncCallback thing is the same as the UsedReferenced2 thing, and thinking about it we should not disallow that one. The only change we want to make here is to not use this kind of resolution on imports.
|
There are two failures in the tink tests:
|
|
Ah I see, that makes a bit more sense! |
* start on m.module_resolution * support static inits * finish module_globals removal * remove wildcard_packages * get cursed resolution tests to pass * add some debug and a test of the current behavior (see #9197) * remove early import resolving and fix python test * turn into class * add RLazy * (finally) remove context_init * don't expand for type lookups * fix 2/3 of broken display test * rename some things * make immutable * add own_resolution * avoid some duplicate lookuppery * distinguish class and abstract statics * move enum expansion to resolution_list * move to own module * add test for alias conflict * add test #closes 2729 * add actual resolve method and try some caching * change expected enum typing * try something different * merge aliases into resolution_kind * remove add_l * add some timers and a type import cache * deal with weirdness * remove weird import lookup see #9150 * meh * asdfg * keep weird handling for now to have CI green * investigate * add timer for flush_pass * add absurd amount of timers * Revert "add absurd amount of timers" This reverts commit 1c49717. * Revert "add timer for flush_pass" This reverts commit 935946b. * Revert "investigate" This reverts commit de52786. * fix test * Remove unused open * remove timers for now --------- Co-authored-by: Rudy Ges <k@klabz.org>
* start on m.module_resolution * support static inits * finish module_globals removal * remove wildcard_packages * get cursed resolution tests to pass * add some debug and a test of the current behavior (see HaxeFoundation#9197) * remove early import resolving and fix python test * turn into class * add RLazy * (finally) remove context_init * don't expand for type lookups * fix 2/3 of broken display test * rename some things * make immutable * add own_resolution * avoid some duplicate lookuppery * distinguish class and abstract statics * move enum expansion to resolution_list * move to own module * add test for alias conflict * add test #closes 2729 * add actual resolve method and try some caching * change expected enum typing * try something different * merge aliases into resolution_kind * remove add_l * add some timers and a type import cache * deal with weirdness * remove weird import lookup see HaxeFoundation#9150 * meh * asdfg * keep weird handling for now to have CI green * investigate * add timer for flush_pass * add absurd amount of timers * Revert "add absurd amount of timers" This reverts commit 1c49717. * Revert "add timer for flush_pass" This reverts commit 935946b. * Revert "investigate" This reverts commit de52786. * fix test * Remove unused open * remove timers for now --------- Co-authored-by: Rudy Ges <k@klabz.org>
The following code currently works, however I am not sure if it's supposed to, because (as far as I understand)
import
statement should only affect unqualified identifier resolution, and NOT fully-qualified (i.e.A
andpack.Module.A
should resolve, butpack.A
should NOT).Main.hx
pack/Module.hx
The text was updated successfully, but these errors were encountered: