Skip to content

CPPIA interpreter: Array<Dynamic>.reverse and resize silently do nothing #409

Open

Description

@dimensionscape

The interpreter accepts reverse() and resize() on an Array<Dynamic> but leaves the array unchanged. For resize it also skips evaluating the size argument.

class Script {
    static var calls = 0;
    static function size():Int { calls++; return 1; }
    static function main() {
        var a:Array<Dynamic> = [1, "two", 3];
        a.reverse();
        Sys.println(a.join(","));
        a.resize(size());
        Sys.println(a.join(",") + " calls=" + calls);
    }
}

Native C++, Haxe Eval and the CPPIA JIT print:

3,two,1
3 calls=1

The CPPIA interpreter prints:

1,two,3
1,two,3 calls=0

Additional checks reproduce the same failure for growing the array and resizing it to zero. A typed Int array reverses and shrinks correctly under both engines.

ArrayBuiltinAny::runVoid and runObject have no dispatch for afReverse or afResize, although createArrayAnyBuiltin accepts both methods. The fallback evaluates the receiver and returns without performing the operation.

Reproduced on Windows x64, Haxe 4.3.7, MSVC 19.44, libhxcpp 4cdca96, release host with -D scriptable --dce no -D HXCPP_M64. The host selects the engine with cpp.cppia.Host.enableJit(false/true) before Host.runFile. Native C++ controls use the same runtime checkout. Current main at 5f7cfef has the same ArrayVirtual.cpp.

Local regression fixture: test/regression/CppiaDynamicArrayMutators/{Script.hx,Main.hx,build.hxml,stdout.txt}. It checks typed controls, reverse, shrink, growth, zero size and argument side effects under both engines. The fixture is uncommitted; no runtime fix is included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions