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

Unclosed monomorphs in function signature #11381

Open
Simn opened this issue Nov 16, 2023 · 0 comments
Open

Unclosed monomorphs in function signature #11381

Simn opened this issue Nov 16, 2023 · 0 comments

Comments

@Simn
Copy link
Member

Simn commented Nov 16, 2023

I randomly found this problem today in the test for #2685:

function main() {
	var a:Int = func1(1);
	$type(func1); // (a : Dynamic) -> Int
	var s:String = func1("foo"); // Int should be String
}

function func1(a:Dynamic) {
	return a;
}

The problem is that the return type of func1 remains a monomorph because those are not bound to Dynamic. It is instead unified with the type of var a:Int and thus the function itself ends up as (a : Dynamic) -> Int, which is just wrong.

Very related to #3033 and I still maintain that functions should not expose their monomorphs. I'll try to see what happens if we bind leftover monomorphs to Dynamic (and maybe Void for some return types?), but I expect some friction here.

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

1 participant