Skip to content
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

importing static fields from classes using @:build doesn't work #2729

Closed
ousado opened this issue Mar 7, 2014 · 3 comments
Closed

importing static fields from classes using @:build doesn't work #2729

ousado opened this issue Mar 7, 2014 · 3 comments
Assignees
Milestone

Comments

@ousado
Copy link
Contributor

ousado commented Mar 7, 2014

Test.hx:

import Test.OtherClass.*;
// import Test.OtherClass.foo;  // fails directly on import

@:publicFields
@:build(Macro.build())
class OtherClass {
    static var foo = 123;   
}

class Test {
    static function main(){
        trace(foo);            // Unknown identifier : foo
    }
}

Macro.hx:

import haxe.macro.Context;
import haxe.macro.Expr;

class Macro {
    static function build():Array<Field>{
        var fields = Context.getBuildFields();
        trace(fields);
        return fields;
    }
}

I'd expect OtherClass.foo to be in scope in Test.main().

@Simn Simn added this to the 3.2 milestone Mar 7, 2014
@Simn
Copy link
Member

Simn commented Mar 7, 2014

This is not a regression, but I find it quite peculiar. It suggests that OtherClass is in a state without any fields at some point, which I don't think should happen with identity build macros.

@Simn Simn modified the milestones: 3.2, 3.3 Mar 24, 2015
@Simn Simn modified the milestones: 3.3.0-rc1, 3.4 Feb 23, 2016
@Simn Simn modified the milestones: 3.4, 4.0 Jan 9, 2017
@Simn Simn modified the milestones: Release 4.0, Bugs Apr 17, 2018
@Simn Simn modified the milestones: Bugs, Later Mar 24, 2023
@Simn
Copy link
Member

Simn commented Oct 20, 2023

Fixed by #11168.

@ousado
Copy link
Contributor Author

ousado commented Nov 22, 2023

wow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants