heap-allocated tuple scrutinee interacts with building a cons whose tail is a recursive call #41

Closed
opened 2026-07-06 20:53:16 +02:00 by st · 0 comments
Owner
This is now well-characterized. The port has surfaced a real compiler backend bug — not a flaw in the branch's stdlib code. Minimal deterministic repro:

fn zw(xs: List[i64], ys: List[i64]): List[i64] =
  match (xs, ys) with
  | ([x | xt], [y | yt]) -> [Num.add(x, y) | zw(xt, yt)]   -- SIGSEGV
  | (_, _) -> []
  end

The trigger is the conjunction of three things — remove any one and it works:
- recursion + a tuple scrutinee (match (xs, ys)) + consing the recursive call as a list tail ([h | zw(...)]).

Evidence:
- dot (same tuple-scrutinee recursion, but returns i64 via Num.add(_, dot(...))) → works (140).
- zw rewritten with nested separate scrutinees (match xs … match ys …, still building a list) → works ([11, 22, 33]).
- non-recursive tuple match, map/foldl with closures → all work.
``` This is now well-characterized. The port has surfaced a real compiler backend bug — not a flaw in the branch's stdlib code. Minimal deterministic repro: fn zw(xs: List[i64], ys: List[i64]): List[i64] = match (xs, ys) with | ([x | xt], [y | yt]) -> [Num.add(x, y) | zw(xt, yt)] -- SIGSEGV | (_, _) -> [] end The trigger is the conjunction of three things — remove any one and it works: - recursion + a tuple scrutinee (match (xs, ys)) + consing the recursive call as a list tail ([h | zw(...)]). Evidence: - dot (same tuple-scrutinee recursion, but returns i64 via Num.add(_, dot(...))) → works (140). - zw rewritten with nested separate scrutinees (match xs … match ys …, still building a list) → works ([11, 22, 33]). - non-recursive tuple match, map/foldl with closures → all work. ```
st 2026-07-06 20:54:51 +02:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
st/amelie#41
No description provided.