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

[CustomJSGenerator] abstract(<typedef>) is incorrectly typed as TAnonymous inside field access #8919

Closed
YellowAfterlife opened this issue Oct 31, 2019 · 1 comment
Labels
Milestone

Comments

@YellowAfterlife
Copy link
Contributor

@YellowAfterlife YellowAfterlife commented Oct 31, 2019

Reproduction snippet: https://gist.github.com/YellowAfterlife/a2aae75d4330c87f1c2f5f977c8b7d1b

In short, you have

class Main {
	static function main() {
		var q:TestAb = {a:"hi!"};
		if (q != null) {
			trace(q.a);
		}
	}
}
@:forward abstract TestAb(TestTd) from TestTd {
	//
}
@:keep typedef TestTd = {
	var a:String;
}

and a CustomJSGenerator that prints TLocal's types:

	function genExpr(e:TypedExpr) {
		function _iter(x:TypedExpr):Void {
			switch (x.expr) {
				case TLocal(v): {
					Context.warning("t=" + x.t + ", v.t=" + v.t, x.pos);
				};
				default:
			}
			TypedExprTools.iter(x, _iter);
		}
		TypedExprTools.iter(e, _iter);
		print(api.generateValue(e));
	}

In 4.0.0 RC3 this prints

src/Main.hx:4: characters 7-8 : Warning : t=TAbstract(TestAb,[]), v.t=TAbstract(TestAb,[])
src/Main.hx:5: characters 10-11 : Warning : t=TType(TestTd,[]), v.t=TAbstract(TestAb,[])
src/Main.hx:8: characters 7-8 : Warning : t=TType(TestTd,[]), v.t=TType(TestTd,[])
src/Main.hx:9: characters 10-11 : Warning : t=TType(TestTd,[]), v.t=TType(TestTd,[])

In 4.0.0 release it prints

src/Main.hx:4: characters 7-8 : Warning : t=TAbstract(TestAb,[]), v.t=TAbstract(TestAb,[])
src/Main.hx:5: characters 10-11 : Warning : t=TAnonymous(<anonymous>), v.t=TAbstract(TestAb,[])
src/Main.hx:8: characters 7-8 : Warning : t=TType(TestTd,[]), v.t=TType(TestTd,[])
src/Main.hx:9: characters 10-11 : Warning : t=TType(TestTd,[]), v.t=TType(TestTd,[])

Note how for abstract_var.field the type of abstract_var is lost and it's just TAnonymous now.

YellowAfterlife pushed a commit to YellowAfterlife/sfhx that referenced this issue Oct 31, 2019
@RealyUniqueName RealyUniqueName modified the milestones: Bugs, Release 4.1 Nov 1, 2019
@RealyUniqueName RealyUniqueName referenced this issue Nov 1, 2019
4 of 4 tasks complete
@RealyUniqueName

This comment has been minimized.

Copy link
Member

@RealyUniqueName RealyUniqueName commented Nov 1, 2019

Bisected to 73a85bf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.