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

Inline constructors vs. Void (continued) #11396

Open
Simn opened this issue Nov 19, 2023 · 3 comments
Open

Inline constructors vs. Void (continued) #11396

Simn opened this issue Nov 19, 2023 · 3 comments

Comments

@Simn
Copy link
Member

Simn commented Nov 19, 2023

This code kills the analyzer with a stack overflow:

function main() {
	[var tmp];
}

While I definitely want to fix that in the analyzer too, the code that comes out of the inline constructor processing has a problem too:

[Function:() -> Void]
        [Block:Array<Void>]
                [Var inlarr_0<6843>(VAssigned):Void]
                [Binop:Void]
                        [Local inlarr_0(6843):Void:Void]
                        =
                        [Block:Void]

There shouldn't be an empty TBlock in a value place.

cc @basro

@basro
Copy link
Contributor

basro commented Nov 19, 2023

I'd expect this to fail during type checking and thus never reach the constructor inliner logic. Is that not supposed to be the case?

@Simn
Copy link
Member Author

Simn commented Nov 19, 2023

It's not always possible during the initial pass because of type inference. A silly example:

function f() {}

function main() {
	var tmp = null;
	[$type(tmp())]; // Unknown<0>
	tmp = f;
	$type(tmp()); // Void
}

Here we don't know the type of tmp while typing the array declaration, and it is later bound to () -> Void. This makes it necessary to check this afterwards, and we currently do that in the analyzer, which runs after inline constructors do.

There may be better ways to handle this altogether, but at the moment it can happen like this.

@basro
Copy link
Contributor

basro commented Nov 19, 2023

Ok, I'll give it some thought.

Maybe cancelling inlining if one of the inlined fields is found to be of type Void would suffice.

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