Summary
Comparing two arrays with == or === is not supported by the EIR backend — for any array type (indexed or associative). This is a general gap, not tied to a specific array shape.
Reproduction
<?php
$a = [1, 2, 3];
var_dump($a === [1, 2, 3]); // unsupported
var_dump(["x" => 1] === ["x" => 1]); // unsupported
var_dump([1, 2, 3] == [1, 2, 3]); // unsupported
elephc:
EIR backend error: unsupported EIR backend feature: strict_eq for PHP type Array(Int)
EIR backend error: unsupported EIR backend feature: strict_eq for PHP type AssocArray { key: Str, value: Int }
EIR backend error: unsupported EIR backend feature: loose_eq for PHP types Array(Int) and Array(Int)
PHP: true / true / true
Root cause
src/codegen_ir/lower_inst/comparisons.rs — the supported type combinations for strict_eq / loose_eq do not include Array(..) or AssocArray, so they fall into the "unsupported EIR backend feature" branch.
- No runtime equality helpers exist (no
__rt_array_eq / __rt_hash_eq).
Scope / semantics
PHP array comparison is non-trivial and recursive:
===: same key/value pairs in the same order, with identical value types.
==: same key/value pairs regardless of order, with value type-juggling.
Implementing this needs new dual-arch runtime routines plus lowering for both operators (and boxed-Mixed element comparison for heterogeneous arrays). Filing as a standalone feature.
Context
Found while reviewing the foreach Mixed-key array-write fix: a rebuilt Array(Mixed) could not be compared against an array literal — but the gap turned out to be general (plain [1,2,3] === [1,2,3] fails too), so it is unrelated to that fix and tracked separately here.
Summary
Comparing two arrays with
==or===is not supported by the EIR backend — for any array type (indexed or associative). This is a general gap, not tied to a specific array shape.Reproduction
elephc:
PHP:
true/true/trueRoot cause
src/codegen_ir/lower_inst/comparisons.rs— the supported type combinations forstrict_eq/loose_eqdo not includeArray(..)orAssocArray, so they fall into the "unsupported EIR backend feature" branch.__rt_array_eq/__rt_hash_eq).Scope / semantics
PHP array comparison is non-trivial and recursive:
===: same key/value pairs in the same order, with identical value types.==: same key/value pairs regardless of order, with value type-juggling.Implementing this needs new dual-arch runtime routines plus lowering for both operators (and boxed-
Mixedelement comparison for heterogeneous arrays). Filing as a standalone feature.Context
Found while reviewing the foreach Mixed-key array-write fix: a rebuilt
Array(Mixed)could not be compared against an array literal — but the gap turned out to be general (plain[1,2,3] === [1,2,3]fails too), so it is unrelated to that fix and tracked separately here.