You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Chained array === with array_unique/array_map is false only in a larger program (semantic suite) #516
A chained && comparison of arrays inside a ternary evaluates to false natively, but only when the program also contains other code. Whole-program dependent miscompile; no single-file repro found yet.
Native output: FAIL dynamic_member_is_uncertain: got [... 3 correct sites ...]. Zend: PASS. Each comparison evaluated into its own variable (or via string-concatenated var_export) is TRUE; only the combined && chain inside the ternary is false.
Reproduce
On the semantic-core P2c tree (bin/manticore freshly built): bash tests/semantic/run.sh -k name_index,tolerant,variables,workspace (~90 s)
PASSES with -k name_index alone and with name_index + any ONE of tolerant/variables/workspace. Needs >= 2 of them.
Reduction so far (all native builds, each ~90 s)
Keeping only some top-level check(...) blocks of the other scripts (name_index.php untouched) still fails with:
tolerant_analysis.php: only check Async spike #4 (broken_use_line_suppresses_undefined_class_o..., line 53)
Dropping half of workspace's checks flips the result either way (first half alone: pass; second half alone: pass; both: fail), so the trigger looks like a whole-program count/ordering effect (type-inference/monomorphization/fused-closure counters), not one construct. A standalone file with the same expression plus 300 extra array_map(fn)/array_unique functions does NOT reproduce.
Related, already fixed: #514 (array === hinted cell elems), #512 (prelude fn specialised too late after fused array_map).
Suggested next step: diff bin/manticore dump-mir --prelude of the failing vs passing combined program around the array_unique(...) call and the cmp === operands (which array_unique$mono$... clone / repr is used).
Narrowing (compiler at semantic-core-p2c 9d33ff5):
The wrong value is the result of array_unique, not the comparison. In the failing combined program, array_unique(array_map(fn($x) => $x->col, $s)) where every col is int returns ["1"]: gettype($c[0]) is string, json_encode prints ["1"], == with [1] is true and === false. The array_map result itself is int.
It is sensitive to the number of array_unique call sites: adding three more calls (literal list, loop-built list, a second array_map result) to the same closure makes all results int and the test pass.
In the failing build the user-code calls do not reach manticore_array_unique by name; its only callers in the IR are __mir_dynft_* trampolines. The closure carries the array_unique work inline (__mir_array_live_len / __mir_array_alloc / __mir_array_value_at / __mir_array_key_cell_at loops).
Repro needs name_index + two or more of tolerant_analysis / variables / workspace: bash tests/semantic/run.sh -k name_index,tolerant,variables,workspace (tests/semantic/run.sh is on branch semantic-core-p2c).
Next step: see which pass decides the specialisation of the prelude array_unique per call site (Monomorphize call keys / SPEC_CAP / the cell-elem dimension) and why the int-element site gets a string-element body when the program has few sites.
No longer reproduces on main 8c817ed + fix/lsp-followups: bash tests/semantic/run.sh -k name_index,tolerant,variables,workspace → 93 PASS / 0 FAIL (dynamic_member_is_uncertain passes); full tests/semantic 744/0. Program-composition dependent, so not proven fixed by a specific change.
Activity
blacktrs commentedon Oct 28, 2026
Narrowing (compiler at semantic-core-p2c 9d33ff5):
array_unique, not the comparison. In the failing combined program,array_unique(array_map(fn($x) => $x->col, $s))where everycolis int returns["1"]:gettype($c[0])isstring,json_encodeprints["1"],==with[1]is true and===false. Thearray_mapresult itself is int.array_uniquecall sites: adding three more calls (literal list, loop-built list, a secondarray_mapresult) to the same closure makes all results int and the test pass.manticore_array_uniqueby name; its only callers in the IR are__mir_dynft_*trampolines. The closure carries the array_unique work inline (__mir_array_live_len/__mir_array_alloc/__mir_array_value_at/__mir_array_key_cell_atloops).name_index+ two or more of tolerant_analysis / variables / workspace:bash tests/semantic/run.sh -k name_index,tolerant,variables,workspace(tests/semantic/run.sh is on branch semantic-core-p2c).array_uniqueper call site (Monomorphize call keys / SPEC_CAP / the cell-elem dimension) and why the int-element site gets a string-element body when the program has few sites.blacktrs commentedon Nov 15, 2026
No longer reproduces on main 8c817ed + fix/lsp-followups:
bash tests/semantic/run.sh -k name_index,tolerant,variables,workspace→ 93 PASS / 0 FAIL (dynamic_member_is_uncertainpasses); full tests/semantic 744/0. Program-composition dependent, so not proven fixed by a specific change.blacktrs commentedon Nov 15, 2026
Closing: does not reproduce (evidence above).