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

[NIGHTLY?] Array getDyn broken #723

Open
NeeEoo opened this issue Oct 29, 2024 · 4 comments · May be fixed by HaxeFoundation/haxe#11810
Open

[NIGHTLY?] Array getDyn broken #723

NeeEoo opened this issue Oct 29, 2024 · 4 comments · May be fixed by HaxeFoundation/haxe#11810

Comments

@NeeEoo
Copy link

NeeEoo commented Oct 29, 2024

Unsure if this also happens in base hashlink since theres no mac build for the stable release.

but

var hello = [];
trace(hello[hello.length - 1]); // crash
hl.types.ArrayDyn.getDyn(/Users/neo/.haxeget/std/hl/types/ArrayDyn.hx:62)
$Main.main(Main.hx:13)
.init(?:1)

haxe version: 4.3.4
hashlink version: 1.14.0

@yuxiaomao
Copy link
Collaborator

yuxiaomao commented Oct 31, 2024

As hello is empty, hello.length - 1 gives -1, and docs https://haxe.org/manual/std-Array.html says:

If a read access is made on a non-existing index, a target-dependent value is returned.
If a write access is made with a negative index, the result is unspecified.

Tested on my machine with latest haxe and hashlink, it gives access violation at https://github.com/HaxeFoundation/haxe/blob/fe0d3e34abb5de658d160eba0b8cc126fab77edc/std/hl/types/ArrayObj.hx#L330 . It does not say what happens when read negative index, but this behavior seems expected.

@Apprentice-Alchemist
Copy link
Contributor

Looking at the code for ArrayObj.getDyn it looks like returning null is the intended behavior, except that comparing UInt and Int generates OJSLt instead of OJULt.

@ncannasse
Copy link
Member

ncannasse commented Oct 31, 2024 via email

@yuxiaomao
Copy link
Collaborator

(You're tagging the wrong people xD, there's another yuxiao s on github!)
Thank you for the tips, will check!

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

Successfully merging a pull request may close this issue.

4 participants