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

Add MDynamic to late-bind monomorphs to Dynamic #11890

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Conversation

Simn
Copy link
Member

@Simn Simn commented Dec 17, 2024

The typer generally avoids binding monomorphs to Dynamic, which has been causing several issues. With this change, unification adds a MDynamic flag to the monomorph and then infers Dynamic if there has been no other unification by the time the monomorph is closed.

This means that it's still a monomorph during typing, as we can see here:

function getArrayDynamic():Array<Dynamic> {
	return ["foo"];
}

function main() {
	var a = getArrayDynamic();
	var b = a[0];
	$type(b); // Unknown<0>
	trace(b);
}

However, the dump now shows [Var b<0>(VUsedByTyper VAnalyzed):Dynamic], which confirms that the monomorph has been bound. This should always be preferable to having dangling open monomorphs, especially when they could appear in a function signature and could be inferred from the outside.

This shouldn't break anything but there's always a chance some code somehow relied on this behavior. It would be good to do a brief check @yuxiaomao.

@yuxiaomao
Copy link
Contributor

Seems good for Shiro's projects.

@Simn Simn merged commit fa2faa1 into development Dec 17, 2024
99 of 101 checks passed
@Simn Simn deleted the mono_MDynamic branch December 17, 2024 10:27
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

Successfully merging this pull request may close these issues.

2 participants