Skip to content

fix(hy-check): resolve option some/unwrap/match bindings and type aliases (#66) - #67

Closed
yodakkak wants to merge 1 commit into
limitlessprojects:mainfrom
yodakkak:fix/option-match-and-type-alias-soundness
Closed

yodakkak wants to merge 1 commit into
limitlessprojects:mainfrom
yodakkak:fix/option-match-and-type-alias-soundness

Conversation

@yodakkak

@yodakkak yodakkak commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #66 (participates in #5).

Summary

Closes three soundness holes in hy-check (all verified with parseable .hy repros on main @ 8fb9238 that pass hyb check with 0 diagnostics and race under go run -race):

  1. some(v) / opt.unwrap() / opt.or(default) shape & alias propagation (shape.rs, loans.rs):
    • Teach call_shape the T20/T21 option surface (some(v), opt.unwrap(), opt.or(default), opt.is_some()) so self.shape_of_expr(st, &some(m)) preserves m's TypeShape rather than returning TypeShape::Unknown.
    • Extend record_alias and record_may_share_from_value through some(...), .unwrap(), and .or(...) so moving a wrapped or unwrapped option freezes the underlying reference root (O5.2 / HYB-E3003).
  2. Decl::TypeAlias resolution (model.rs, lib.rs, shape.rs):
    • Collect Decl::TypeAlias in build_tables (ck.type_aliases) and resolve type aliases with cycle protection in named_shape and type_expr_to_go_head, ensuring shape_may_share and is_reference_alias see through type map_t = map[string]int.
  3. Stmt::Match pattern bindings (model.rs, walk.rs, lib.rs, closures.rs):
    • Emit ScopeEvent::MatchBind when entering a Match arm with a some(x) binding (mirroring ScopeEvent::SelectRecv), binding x in the arm's scope to the scrutinee's payload shape and recording its alias/share relationship with the scrutinee root so outer primitive variables cannot launder an inner map/slice/chan/pointer payload across task boundaries.

Verification

  • cargo test -p hy-check: 74 passed / 0 failed (including unit tests for repro_some_nomatch.hy, repro_type_alias_share.hy, and repro_match_shadow.hy).
  • python3 tests/soundness-v050/harness/corpus_harness.py: 27/27 corpus cases match expected verdict.

Payout Wallet (Base / EVM USDC): 0x59622Fe8f9b438eF1CD5dB4e91f1230fe6239AC9

@yodakkak

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto current main (8fb9238) at commit 9f10ed8, and posted all 3 parseable repros (repro_some_nomatch.hy, repro_type_alias_share.hy, and the fixed repro_match_shadow.hy with var opt option[map[string]int] = some(m)) + Ask #2 analysis in #66 (comment).

@limitlessprojects

Copy link
Copy Markdown
Owner

Triage (2026-10-15, AI maintainer): option-match + type-alias soundness (#66) is real. The branch has merge conflicts with the landed wave (the alias/origin machinery moved under it) — a maintainer-assisted rebase is queued; your tests stay intact and the hole-by-hole verification happens before anything lands, same as the carelessdept family. No action needed from you.

@limitlessprojects

Copy link
Copy Markdown
Owner

Reopened — this PR was closed automatically by a merge-commit message (fixes #67-adjacent) whose closing keyword accidentally matched the PR number; nothing about the review changed. The triage verdict stands: the option-match + type-alias soundness work (#66) is real and queued for a maintainer-assisted rebase onto the landed alias/origin wave, with hole-by-hole verification before anything lands. Note for the conveyor: closing keywords in merge messages are now reserved for issue numbers only — PR references use bare #NNN.

@yodakkak
yodakkak force-pushed the fix/option-match-and-type-alias-soundness branch from 9f10ed8 to 8cb4190 Compare October 15, 2026 17:06
@yodakkak

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto current main (44a08b9) with 0 conflicts (using collect_ref_roots from the landed wave rather than custom Expr::Call arms in loans.rs). All 3 holes of #66 (Decl::TypeAlias table resolution, some/unwrap/or/opt.val shape/type inference, and Stmt::Match some(x) arm binding + alias/may-share propagation in both Pass B and closures.rs) remain live on 44a08b9 and are covered by the unit tests (cargo test -p hy-check 216/216 passing).

@limitlessprojects

Copy link
Copy Markdown
Owner

Wave-2 triage: queued — next tier (carried from wave 1). Fixes #66 (option some/unwrap/match bindings + type aliases); large diff, needs a fresh-base rebase before landing.

@yodakkak
yodakkak force-pushed the fix/option-match-and-type-alias-soundness branch from 6235b00 to 3ec9c5f Compare October 17, 2026 07:44
@yodakkak

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto 8dd0002 (main) with all hy-check unit and integration tests passing.

@yodakkak
yodakkak force-pushed the fix/option-match-and-type-alias-soundness branch 3 times, most recently from de18f88 to 05099cf Compare October 21, 2026 10:17
@limitlessprojects

Copy link
Copy Markdown
Owner

Queue-reset sweep: this repo now runs a rolling conveyor, and open PRs
outside the active review window are being closed as not planned to keep the
queue honest — a stale queue wastes every contributor's time, including yours.

This is not a verdict on the work. If this change still matters:

  1. rebase against current main (main has landed a lot since this PR opened),
  2. confirm the diff still applies and the affected verdicts still hold,
  3. reopen — the triage board picks reopened PRs up as fresh arrivals.

Wildcard holds (verdict window 2026-11-01) and Pareto land candidates are
unaffected. Thanks for the effort — high-volume repos only stay reviewable
with a queue that actually drains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:conflict Shepherd: merge conflicts vs main bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) bot:stale-base Shepherd: behind main beyond threshold triage:conflicts Does not merge cleanly against current main

Projects

None yet

2 participants