Commit 4b85f11
authored
Fix gentrace assertions when tracing tuples containing type aliases (#5196)
PR #5145 stopped expanding type aliases during name resolution, so a
type alias now persists as TK_TYPEALIASREF through codegen. Every
codegen dispatch site was updated to unfold TK_TYPEALIASREF on demand,
but two sites in gentrace.c were missed. Both only surface when a tuple
is traced dynamically (e.g. as an element of a union), which is why
ponylang/crdt's nightly started failing its build after #5145 landed:
its `_Dot is (ID, U64)` alias wrapping a tuple exercises the first of
these paths.
trace_dynamic_tuple's TRACE_TUPLE branch duplicated the alias ref with
ast_dup and passed it to the recursive trace_dynamic_tuple, which then
iterated the alias ref's TK_ID / typeargs / cap / eph children as if
they were tuple elements and tripped trace_type's default assertion.
Unfold the alias once before the recursion so the callee sees the
concrete TK_TUPLETYPE.
trace_dynamic's TK_TYPEALIASREF case called typealias_unfold (which
always returns a detached subtree) and passed the detached tree into
the recursive trace_dynamic. When the detached subtree contained a
tuple that reached trace_dynamic_tuple with tuple != NULL, the
ast_swap(type, dontcare) at the top of trace_dynamic_tuple asserted on
the NULL parent. Splice the unfolded form into the alias's position in
its parent so downstream ast_swap always sees an attached tree; the
rare detached-alias case is only reachable when tuple == NULL, so the
in_tuple branch is never taken and the missing parent does not matter.
A single regression test under test/full-program-tests exercises both
scenarios: one field with an alias that expands directly to a tuple
(bug 1) and another field with an alias that expands to a union
containing a second alias-to-tuple (bug 2).
Chained type aliases (alias of alias of tuple) are a known gap in the
TRACE_TUPLE fix — typealias_unfold only unfolds one level. Constructing
a test that reaches this site with a chained alias is currently blocked
by other #5145 regressions elsewhere in codegen (the static trace_tuple
path in gentrace.c and gen_digestof_value in genreference.c), which
fire first for every configuration tried. That broader audit of every
typealias_unfold call site is tracked in #5195.
This is a regression against unreleased code, so no changelog or
release notes entry.1 parent 10b48a3 commit 4b85f11
File tree
2 files changed
+71
-2
lines changed- src/libponyc/codegen
- test/full-program-tests/type-alias-tuple-trace-union
2 files changed
+71
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
818 | 841 | | |
819 | 842 | | |
820 | 843 | | |
| |||
950 | 973 | | |
951 | 974 | | |
952 | 975 | | |
953 | | - | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
954 | 999 | | |
955 | 1000 | | |
956 | 1001 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments