-
-
Notifications
You must be signed in to change notification settings - Fork 662
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] no private field control for exprs generated with macro #3714
Comments
That's the |
Haha, we celebrate christmas two weeks later here so I had no idea :-P Anyway, it looks quite sloppy to me having |
That's indeed an issue, I think we should keep it open :) |
We designed it like this on purpose, but I really don't remember why. Chances are @back2dos was involved. |
I think this came up because of how static extension macros worked, i.e. round tripping expressions through the typer, which meant that for example a field read access would become a call to the private getter, so when you returned that back, you got type errors from the private access. However because since 3.1.0 the expressions are handled differently I would speculate that this is now obsolete. If this is was the only reason, then the Personally, I always add |
Static extensions were the only reason I could think of too, and I agree with your conclusion. Thanks for remembering! |
I wonder if we should revert this. It seems to cause a bit of confusion because it's hard to tell where the problem comes from. |
Could we then add |
I'm not sure what that would actually improve... |
I remember writing some syntax-sugar macros where I didn't want to loose access control to keep things error-proof, that's why I reported this issue. I don't remember the exact case, but I'm sure there are plenty of use cases. |
Yeah but that shouldn't be about specific types. If anything we should have a -D flag for this. We could go for a general |
Actually, I remember you writing a macro that allows to do: myObj.with(
a = 1,
doStuff()
); which is then translated to myObj.a = 1;
myObj.doStuff(); It would make perfect sense to keep access restrictions in such case. |
I don't follow. Do you want to keep old "everything is public within a macro" behaviour, but hide it behind |
(also I'm worried about libraries defining that flag with extraParams.hxml) |
I meant the opposite. Do I really have to worry for every single flag about libraries possibly defining them? There's always the option to tell such a library author that he's being an idiot. Anyway, I have reverted the change, feel free to add whatever you feel is right but please keep this as the default. |
Maybe improving the error report suggesting to use "@:privateAccess". Oh too late, not the default now. |
Just after I pushed the |
I still think it's weird to implicitly lose access control when calling a macro by default. Macros are supposed to be ast transformations and having that side effect is unexpected. |
By the way, I noticed that E.g. this will fail with class A {
static var a:Int;
}
class Main {
static function main() {
m();
}
static macro function m() return macro A.a;
} |
I don't disagree but it still presents a problem that is really hard to track down, especially for mere users of a macro (library). |
Firstly, I think removing this auto-generated @:privateAccess is the right Given the circumstances, I thought it would be the best thing we could Secondly, macro libraries are still very exotic and largely only used by From Haxe 3 on, every release broke something about macros. And I think it The @:noPrivateAccess thing is still pretty useful I think, but On Thu, Mar 26, 2015 at 5:12 PM, Simon Krajewski notifications@github.com
|
I don't agree with the revert of the change : I think that we should not add @:privateAccess and let the macro authors deal with the change, which was a "bug" IMHO to let accessing all privates as soon as you had an expr returned from macro. |
It was not a bug, it was a deliberate implementation in the past and just because nobody remembers the exact reasoning doesn't mean that we can just discard it. There have been multiple reports of it in the RC phase and most users who are affected by this cannot fix it by themselves. This is very frustrating and adds to the perception of Haxe being unstable. |
Yes I understand how it was not a bug, but if we are planning to change that at some point (and we do), the the sooner the better. Haxe is growing, and the number of users/libraries as well. So let's make the change asap and help library authors to fix their code, or else it will be even harder and will affect even more users to do that for the next version. |
I lack the energy to discuss this further. I have reverted the change. |
That was unexpected, but I'm certainly fine with it :-) I mentioned the change in https://github.com/HaxeFoundation/haxe/wiki/Breaking-changes-in-Haxe-3.2.0#macro. |
I feel like this should fail to compile with
Cannot access private field id
error, shouldn't it?The text was updated successfully, but these errors were encountered: