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

JvmCode.EmptyStack #10405

Closed
kevinresol opened this issue Sep 27, 2021 · 2 comments
Closed

JvmCode.EmptyStack #10405

kevinresol opened this issue Sep 27, 2021 · 2 comments
Assignees
Labels
bug platform-jvm Everything related to JVM

Comments

@kevinresol
Copy link
Contributor

0c89b91

The following code will produce JvmCode.EmptyStack

extern interface Overloaded {
	overload function onEvent(v:Int):Void;
	overload function onEvent(v:String, opt:Bool):Void;
}
class Main implements Overloaded {
	static function main() {}
	public overload function onEvent(v:Int) {}
	public overload function onEvent(v:String, opt:Bool) {
		trace({v: try '' catch(_) null});
	}
}

However, it will compile fine if the order of the 2 onEvent implementations are reversed.

@RealyUniqueName RealyUniqueName added bug platform-jvm Everything related to JVM labels Oct 12, 2021
@RealyUniqueName RealyUniqueName added this to the Bugs milestone Oct 12, 2021
@Simn Simn self-assigned this Oct 18, 2021
@Simn
Copy link
Member

Simn commented Oct 18, 2021

class NotMain {

	public overload function onEvent(v:Int):Void {}

	public overload function onEvent() {
		trace(try '' catch (_) null);
	}
}

function main() {}

The overloads are relevant because, as it turns out, the analyzer doesn't run on overloads and thus doesn't clean up the code. However, this shouldn't fail regardless, so there must also be a problem related to the try/catch handling in genjvm.

@Simn
Copy link
Member

Simn commented Oct 18, 2021

Actually it's not specific to try/catch:

class NotMain {

	public overload function onEvent(v:Int):Void {}

	public overload function onEvent() {
		var b = Math.random() > 0.5 ? 1 : throw "no";
	}
}

function main() {}

I'll rely on the analyzer transformation here because otherwise I would have to deal with this entire terminating-statements-in-value-places-situation in the generator again, which seems annoying and pointless.

Simn added a commit that referenced this issue Oct 18, 2021
@Simn Simn closed this as completed Oct 18, 2021
RealyUniqueName added a commit that referenced this issue Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-jvm Everything related to JVM
Projects
None yet
Development

No branches or pull requests

3 participants