Repository navigation
Let a start read from a Dynamic field reach indexOf and lastIndexOf - #506
Open
dimensionscape wants to merge 1 commit into
Open
dimensionscape wants to merge 1 commit into
dimensionscape wants to merge 1 commit into
Conversation
Since aaf0388, a String's and a typed Array's indexOf and lastIndexOf have an Int overload beside the Dynamic one, and null() an overload of its own. A start read from a Dynamic field, as in text.indexOf(" ", o.start), is an hx::Val, which converts to both an Int and a Dynamic, so generated code that passes one stopped compiling: C2668 on MSVC, "call to member function 'indexOf' is ambiguous" on clang. hxc's WebAssembly build fails this way in its own source. A template overload now takes a start of any class type that no other overload matches exactly and passes it on as a Dynamic, as every start went before aaf0388. Int, Dynamic and null() starts keep their own overloads, so an Int start is still not boxed. In hxString.h the conversion goes through a defaulted template parameter, because Dynamic is not complete there. Tests: TestSearch in test/haxe compares a start read from a Dynamic field with the other kinds, on Strings and Int arrays. Without the change TestSearch.cpp does not compile (C2668 on all four calls); with it test/haxe passes on Windows x64, 2880 assertions.
dimensionscape
added a commit
to DimensionscapeOrg/haxe-run
that referenced
this pull request
Nov 28, 2026
The compiler is hxc-release 2b4612e1, as before, now built against openfl/libhxcpp b4a66042: main at b6981ce4 plus the indexOf fix of openfl/libhxcpp#506. Since 6.0.0 a start read from a Dynamic field no longer compiled there, and hxc's own source passes one. libhxcpp's emscripten toolchain now strips the linked module, which took the function names out, so the build passes -Dnostrip. WORKER_CONTRACT.md records both, and building against a copy of libhxcpp through HAXELIB_PATH. Output is unchanged: the shared ES5 sample, try.haxe.org's sample at its ES6 and full DCE settings, and PiratePig compile byte for byte as with stock Haxe, bar Lime's random asset cache version and one float literal the wasm build already printed with an extra digit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For 6.0.3. Fixes a regression in 6.0.0 from aaf0388 (#307).
Generated code that passes a start read from a Dynamic field to a String's or a typed Array's
indexOforlastIndexOfno longer compiles:hxc does this in its own source, so its WebAssembly build stopped there under emscripten's clang.
Cause
aaf0388 gave these methods an Int overload beside the Dynamic one, so an Int start is not boxed, and one for
null(), which converts to both. A Dynamic field read is anhx::Val, which also converts to both an Int and a Dynamic, so a call that passes one matched two overloads equally well.Change
A template overload takes a start of any class type that no other overload matches exactly and passes it on as a Dynamic, as every start went before aaf0388. Int, Dynamic and
null()starts keep their own overloads, so an Int start is still not boxed, and other arithmetic types still convert to Int as before. Ininclude/hxString.hthe conversion goes through a defaulted template parameter, becauseDynamicis not complete there. Four declarations, ininclude/hxString.handinclude/Array.h.Tests
TestSearchintest/haxenow also passes the start through a Dynamic field, on Strings and Int arrays, and compares it with the other kinds. Without the changeTestSearch.cppdoes not compile (C2668 on all four calls); with ittest/haxepasses on 64-bit Windows with MSVC and Haxe 4.3.7, 2880 of 2880 assertions.hxc's WebAssembly build (emscripten 3.1.74) compiles and links against this branch.