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

[js] Regression with null safety diagnostics #11904

Open
RblSb opened this issue Dec 29, 2024 · 1 comment
Open

[js] Regression with null safety diagnostics #11904

RblSb opened this issue Dec 29, 2024 · 1 comment
Milestone

Comments

@RblSb
Copy link
Member

RblSb commented Dec 29, 2024

In nightly builds after file resave this error occurs: (no compilation errors). From vshaxe codebase, doesn't happen on interp.
Main.hx:

using StringTools;

@:nullSafety
class Main {
	static function main() {}

	static function extractReturnType(hint:String):Void {
		// Null safety: Cannot unify String with { charCodeAt : Int -> Int }
		for (i => code in hint) {}
	}
}
-cp src
-main Main
--js bin/main.js
@RblSb
Copy link
Member Author

RblSb commented Jan 4, 2025

Minimized example: StringTools.unsafeCodeAt("foo", 0).

This basically inlines return (cast s).charCodeAt(index):
https://github.com/HaxeFoundation/haxe/blob/development/std/StringTools.hx#L504

Not really a regression, happens since c4cc470

Unification errors here on TAbstract(Null, [TAbstract(Int, [])]) and TAbstract(Int, []) comparison (idk how is first type is maked here).
https://github.com/HaxeFoundation/haxe/blob/development/src/typing/nullSafety.ml#L233

Interestingly, this error does not happen if you copy unsafeCodeAt function to Main class and call it. But error will happen on file resave if you create separate class and call it like Tools.unsafeCodeAt("foo", 0), so it looks like server cache problem related to modules, and not a null safety cache thing.

@kLabz kLabz added this to the 5.0 preview 1 milestone Jan 21, 2025
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