haxe icon indicating copy to clipboard operation
haxe copied to clipboard

[nullsafety] Non-nullable check warnings

Open RblSb opened this issue 6 months ago • 2 comments

Cannot undestand problem with warning diagnostics, need some help: (nullsafety warnings will stay if there is nullsafety errors btw)

@:nullSafety
@:haxe.warning("-WRedundantNullCheck")
class Main {
	static function main() {
		new Main();
	}

	function new() {
		final foo = "1";
		// this warning doesn't react on WRedundantNullCheck
		// and also hides after vscode tab swap
		final v = foo ?? "0";

		final foo = 1;
		// no warning because of Null<Int> cast in operator
		// probably can be fixed with some @:nonNullable internal meta on expr
		final v = foo ?? 0;

		// working warning example
		final f:Int;
		function name():Void {
			f + 1;
		}
	}
}

Closes https://github.com/HaxeFoundation/haxe/issues/7816

RblSb avatar May 10 '25 15:05 RblSb