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

[nullsafety] Cannot disable field initialization check with @:nullSafety(Off) #9643

Closed
haxiomic opened this issue Jun 23, 2020 · 0 comments
Closed
Labels

Comments

@haxiomic
Copy link
Member

haxiomic commented Jun 23, 2020

I have a case where I know all fields will be initialized when accessing this, but I cannot disable the nullSafety error for that case:
Tested in haxe 4.0.5, 4.1.2 and latest development to c862176

import js.lib.Promise;

@:nullSafety
class Main {

	final field: String;

	public function new() {
		new Promise((resolve, reject) -> {
			@:nullSafety(Off) method(); // still errors
		});
		field = 'hello';
	}

	function method() {
		
	}

	static function main() new Main();

}

Error is
Main.hx:10: characters 22-28 : Null safety: Cannot use "this" until all instance fields are initialized.

Attached repro

(While in this example I could just move field initialization before the promise, in my project that is not possible)

null-safety-issue.zip

@RealyUniqueName RealyUniqueName added this to the Bugs milestone Jun 24, 2020
@RealyUniqueName RealyUniqueName modified the milestones: Bugs, Hotfix Jun 24, 2020
@RealyUniqueName RealyUniqueName modified the milestones: Hotfix, Bugs Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants