Repository navigation
Sema: a join arm typed as a bare generic (Vec.new()) records the join's type (#1393) - #1418
Conversation
2be8cd8 to
4b8b601
Compare
|
Batch battery X2 (seed-driven, NEW seed, with :drop-audit/:move-audit) on main 977e667 + #1404 → #1418 → #1419 → #1425 (head ee4e2e4, including the #1404/#1418 join-arm merge resolution): build ok, :fixpoint ok, :drop-audit ok, :move-audit ok, :test ok (no reds), :test-green ok, :last-green ok. #1424's four repros run clean on this build. Branches hold exactly the tested chain; merge in order #1404, #1418, #1419, #1425 — then batch Y (#1405 … #1360), then #1428. |
4b8b601 to
777fb39
Compare
|
Battery (seed-driven, new seed, with :drop-audit/:move-audit) on main 05b674e (incl. batch Y) + #1418 → #1419 → #1425 → #1428 (head eea9017): build ok, :fixpoint ok, :drop-audit ok, :move-audit ok, :test ok (no reds — including #1422's da_option_filter_observes_payload, so this clears main's #1424 red), :test-green ok, :last-green ok. Merges cleanly into main 1c76062. Now GitHub stack #1437 (gh stack link); merge the whole stack: |
…in's type (#1393) Route: MIR lowering failure — WITH_MIR_AUDIT, lldb on mark_unsupported, analyze facts for the arm node. `say(&o.unwrap_or(Vec.new()))` failed: `[mir-lower-fail] kind=27 fn=main span=118..127` (the `Vec.new()`), `error: code generation failed`. So did `o.unwrap_or(Vec.new()).len()`, `&r.unwrap_or(Vec.new())` and `(o ?? Vec.new()).len()`; `let v = o.unwrap_or(Vec.new())` compiled. Evidence: - lldb, breakpoint on MirBuilder.mark_unsupported: lower_un_op (the `&`) -> lower_expr_place -> lower_method_call -> lower_unwrap_or_method -> lower_method_call -> lower_intrinsic_call -> mark_unsupported. In lower_intrinsic_call a static constructor (VEC_NEW) whose method_call_result_type is the bare struct borrows the type from `self.expected_type` only when that is the matching GENERIC_INST; under `&` it is `&Vec[i32]` (as a receiver, nothing), so ret_type stays the bare TY_STRUCT and MirLower.w's `ret_tk2 == TypeKind.TY_STRUCT` branch calls mark_unsupported. - `with analyze repro.w explain:node:577319` (the `Vec.new()` node), base stage1: `type=Vec`. The join had settled `Vec[i32]` but never recorded it on the arm; the `let` form only worked because lower_let's expectation happened to be `Vec[i32]`. Exact line: SemaCheck.resolve_contextual_join completes an arm after the final type is known only when the arm's type is 0 (variant shorthands). An EXPR arm typed as the bare generic base of the final type kept that type. Fix (§3.8/§10: the join fixes the arm's type): the completion loop records the final type on an EXPR arm whose type is the bare generic base of it (typed_expr_types and the recorded arm type), so lowering the arm no longer depends on the surrounding expectation. After: explain:node:577319 reads `type=Vec[i32]`; the repro prints 0. Matrix (test/debug_alloc/da_join_default_bare_generic_any_context.w, leak count 0, exact stdout): unwrap_or on Option / Result × both paths, under `&` and as a method receiver; `??` as a receiver and under `&`; HashMap; an owned call argument; `if` and `match` arms under `&` / bound. Base stage1 (fix-1363-unwrap-or-str): MIR lowering failed. The 92 d22 / §10 / §3.8 / carrier-eliminator fixtures: every failure also fails on the base (test/non_compliant/d22/*, two phase dumps). Typing change only: no drop scheduling or ownership lowering changed. Shares type_is_generic_base_of with #1378's branch (same helper text). Fixes #1393.
777fb39 to
9b05af8
Compare
|
Stack #1466 battery (seed-driven, new seed, cold c_import cache, with :drop-audit/:move-audit) on main 1c76062 + #1418 → #1419 → #1425 → #1428 → #1449 → #1377 → #1459 → #1460 → #1461 → #1462 (head cf36211, including the #1449/#1462 Codegen resolution and the fixed #1460): build ok, :fixpoint ok, :drop-audit ok, :move-audit ok, :test ok (no reds), :test-green ok, :last-green ok. Each branch holds exactly its tested commits on the layer below. Merge the whole stack: |
Fixes #1393. Stacked on #1398 (branch
fix-1363-unwrap-or-str). Sibling of #1404 (#1378): both add the sametype_is_generic_base_ofhelper and both extend the same completion loop inresolve_contextual_join, so whichever lands second has a trivial conflict.Root cause
say(&o.unwrap_or(Vec.new()))failed with[mir-lower-fail] kind=27at theVec.new()span. So dido.unwrap_or(Vec.new()).len(),&r.unwrap_or(Vec.new())and(o ?? Vec.new()).len().let v = o.unwrap_or(Vec.new())compiled.MirBuilder.mark_unsupported. The call path is:lower_un_op(the&) →lower_expr_place→lower_unwrap_or_method→lower_method_call→lower_intrinsic_call→mark_unsupported.lower_intrinsic_call, a static constructor whose result type is the bare struct takes its type fromself.expected_type, but only when that is the matching generic instance. Under&the expected type is&Vec[i32], and as a receiver there is none. Soret_typestays the bareTY_STRUCTand hitsmark_unsupported.with analyze repro.w explain:node:577319(theVec.new()), base:type=Vec. The join settled onVec[i32]but never recorded it on the arm. Theletform only worked becauselethappened to supply the right expectation.resolve_contextual_join(src/SemaCheck.w) completed an arm only when its type was 0 (variant shorthands).Fix
Per §3.8/§10, the join decides the arm's type. An EXPR arm whose type is the bare generic base of the final type now records the final type, both on the node and on the recorded arm. After the fix, the same query reads
type=Vec[i32]and the repro prints0.Matrix
test/debug_alloc/da_join_default_bare_generic_any_context.w(leak count 0, exact stdout):&and as a method receiver??as a receiver and under&if/matcharmsOn the base it fails MIR lowering.
Local evidence (iterate tier, stage1 from this branch)
with check src/main.w: okThis changes typing only. It does not change drop scheduling or ownership lowering. Full battery not run, so this stays a draft.