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

@:structInit ambiguity when @:from between abstract forwarded types #11586

Open
nspitko opened this issue Feb 20, 2024 · 1 comment
Open

@:structInit ambiguity when @:from between abstract forwarded types #11586

nspitko opened this issue Feb 20, 2024 · 1 comment

Comments

@nspitko
Copy link

nspitko commented Feb 20, 2024

Oh god I hope this title makes sense.

This is a followup to #11535, it seems I cut down my repro a bit too much to expose all the fun exciting quirks.

The fix for the previous issue works fine for direct classes, but breaks when pointing through abstracts, as below. The only change from the previous repro is that we're now coming @:from the Bar abstract instead of BarImpl directly.

Tested against haxe nightly 6ab9980

Repro:

// Bar 
// Removing this @:structInit will fix the build.
@:structInit
class BarImpl {
	public function new() {}
}

@:forward
abstract Bar(BarImpl) from BarImpl to BarImpl {
}

// FooImpl
@:structInit
class FooImpl {
	public var x:Float;

	public function new(x:Float) {
		this.x = x;
	}
}

// Foo
@:forward
abstract Foo(FooImpl) from FooImpl to FooImpl {
	public function new(x:Float) {
		this = new FooImpl(x);
	}

	@:from
	static public function fromBar(v:Bar):Foo {
		return new Foo(1);
	}

}

// Main
class Test {
	static function main() {
		var v:Foo = {x: 2};
		trace(v.x);
	}
}

try.haxe: https://try.haxe.org/#54AAA5cC

@nanjizal
Copy link
Contributor

var v:Foo = ({x:2}:FooImpl);

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

2 participants