Skip to content

fix for loops crashing on hashlink - #33

Merged
Jamextreme140 merged 3 commits into
CodenameCrew:codename-devfrom
Villezen:fix-for-loops
Nov 24, 2026
Merged

Jamextreme140 merged 3 commits into
CodenameCrew:codename-devfrom
Villezen:fix-for-loops

Conversation

@Villezen

Copy link
Copy Markdown

on hashlink, every normal for loop crashes with Can't cast i32 to virtual<key:dynamic,value:dynamic>

This happens because next had no type, so haxe expected every value to have both a key and value field, which ints for example don't have

This turns next into Dynamic so it accepts any value properly

@Jamextreme140 Jamextreme140 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please put your code inside a compilation flag since the current implementation is optimized for C++

Like:

#if hl
var it:Iterator<Dynamic> = makeIterator(expr(it), isKeyValue);
#else 
var it = makeIterator(expr(it), isKeyValue);
var _hasNext = it.hasNext;
var _next = it.next;
#end

@Jamextreme140 Jamextreme140 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to do the same for the loop:

while (#if hl it.hasNext() #else _hasNext() #end) {
    var next:Dynamic = #if hl it.next() #else _next() #end ;
    // ...
}

@Villezen

Copy link
Copy Markdown
Author

Oops sorry 😭 I did that commit on my phone I'll make sure everything's added when I come home

@Jamextreme140
Jamextreme140 merged commit ac366a3 into CodenameCrew:codename-dev Nov 24, 2026
1 check passed
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 this pull request may close these issues.

2 participants