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

Accessing super from a local function #11672

Closed
Speedphoenix opened this issue May 16, 2024 · 1 comment
Closed

Accessing super from a local function #11672

Speedphoenix opened this issue May 16, 2024 · 1 comment

Comments

@Speedphoenix
Copy link

I have a case like this

class A {
	function trySomething() {
		trace("tried");
	}
}

class B extends A {
	function askConfirm(onConfirm:Void->Void) {}

	override function trySomething() {
		function continueTrying() {
			trace("more stuff");
			super.trySomething();
		}
		if (true) {
			askConfirm(() -> continueTrying());
		} else {
			continueTrying();
		}
	}
}

but super.trySomething() gives me

Cannot access super inside a local function
Try Haxe

So I need to create a separate same-scope function that is meant to be used exclusively inside trySomething(), which I would rather not have to do

Is there any chance we'd be able to use super in local functions in the future?

@Simn
Copy link
Member

Simn commented May 16, 2024

No, this cannot be implemented on all targets.

@Simn Simn closed this as completed May 16, 2024
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