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

Abstract Macro @:op(A.B) overloading weird #10793

Closed
filt3rek opened this issue Sep 7, 2022 · 1 comment
Closed

Abstract Macro @:op(A.B) overloading weird #10793

filt3rek opened this issue Sep 7, 2022 · 1 comment
Assignees
Labels
platform-macro Everything related to Haxe macros

Comments

@filt3rek
Copy link
Contributor

filt3rek commented Sep 7, 2022

Hej,

Sorry I don't know if it's a bug or maybe I don't understand things. I tried to do a minimalistic example to illustrate what's going on : https://try.haxe.org/#B33dD5ED

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

using haxe.macro.Tools;

abstract Foo(Dynamic) from Dynamic to Dynamic {
	@:op(A.B) function get(prop:String) {
		return Reflect.field(this, prop);
	}

	@:op(A.B) macro function set(obj:Expr, prop:Expr, val:Expr) {
		trace(Context.getTypedExpr(Context.typeExpr(obj)).toString(), prop.toString(), Context.getTypedExpr(Context.typeExpr(val)).toString());
		return macro $val;
	}
}

class Test {
	static function main() {
		var foo:Foo = {
			n: 5
		};
		foo.n = 4;	// compiler trace => foo,"n",4 => So "obj" = "foo" OK
		foo.n += 4;	// compiler trace => Test.Foo_Impl_.get(foo, "n") + 4,"n",Test.Foo_Impl_.get(foo, "n") + 4
				// So "obj" = "Test.Foo_Impl_.get(foo, "n") + 4" ???
	}
}

Is it normal please ?

@Simn Simn self-assigned this Sep 28, 2022
@Simn Simn added the platform-macro Everything related to Haxe macros label Sep 28, 2022
@Simn
Copy link
Member

Simn commented Sep 28, 2022

I think this is about how we handle @:this this expressions, which is probably not general enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-macro Everything related to Haxe macros
Projects
None yet
Development

No branches or pull requests

2 participants