Skip to content

cppia jit: Array contains, remove and Array<Bool> element results are boxed as Int #260

Closed

Description

@dimensionscape

In the cppia jit, Array.contains and Array.remove results, and Array<Bool> elements read or written, become an Int instead of a Bool when they are boxed to Dynamic. The interpreter and C++ give Bools.

var a = [1, 2, 3];
var flags = [true, false, true];
var row:Array<Dynamic> = [a.contains(1), a.remove(3), flags[0], flags[1] = false];
Sys.println(row + " " + [for (x in row) Std.isOfType(x, Bool)]);

C++ and the cppia interpreter print [true,true,true,false] [true,true,true,true]. The jit stored 1, 1, 1 and 0, none of them a Bool.

The jit carries Bools as Int and asks an expression's isBoolInt() when it boxes one. ArrayVirtual answered it for remove and contains, but the typed ArrayBuiltin did not, and neither did the Bool element get and set or ArraySetter.

The cross-target output comparison (#150) found it on its first run: the jit was the only engine whose output differed from C++. Related to #134, which fixed other Bool results that came back as Int. #259 is a separate path: a Bool stored in a dynamic field.

Activity

  1. dimensionscape commented on Oct 22, 2026

    @dimensionscape
    MemberAuthor

    Fixed in a7273a8: ArrayBuiltin and ArraySetter now report Bool results through isBoolInt(), and CppiaBoolBuiltins covers the literal above in the interpreter and the jit.

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