Claim Match-arm binders as fresh identities in the v3 order judgment

Open
#304 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Start in crates/amblicit-syntax/src/target_ir/execution_order.rs around line 297 and read the v3 order judgment, then inspect the three isolated probes described in the issue. Add refusal witnesses for each reused identity and a passing witness for a fresh Match binder; update TIR-REQ-060, its test-plan rows, and the named caveat references. Decide whether the String-scrutinee case belongs here or in a separate issue. Done means the specified cargo test and cargo xtask verify pass after PR #303 merges.

Written by the indexing model from the issue text.

Description

bug enhancement release:target-ir

Size: small (under 4 hours). One issue, one PR.

Problem

The structured Target v3 order judgment claims fresh identities for instruction results, obstruction binders and loop binders, but a CoreExpr::Match arm binder is introduced without being claimed. At crates/amblicit-syntax/src/target_ir/execution_order.rs#297@cebf7da the binder goes through introduce but not claimed. So an identity can appear twice in one intent and still pass the judgment.

This was found during the Baker Street review of PR #303 (cross-examination row 6). Each probe below was isolated through encode_target_ir_artifact, and each was admitted:

  • A Match in root binding.2 whose binder reuses nested local.2, which is out of scope at that point.
  • A Match in binding.0 whose binder reuses the later loop binder id.
  • A Match in binding.2 whose binder reuses the loop binder id.

The same change made on both the Core and Target sides also passes emit_result_projection. Whether this matters at runtime is unproven: the scopes are disjoint, so it may be harmless.

There is also an open question to settle here. In the same probe, a Match with case "some" over a String scrutinee was admitted at this layer.

Outcome

Under echo.span-ir/v3, a Match arm binder that reuses any identity already claimed in the intent refuses with InvalidCoreIdentity, detail identity_not_fresh or the existing equivalent, and produces no artifact.

Scope

  • Claim Match arm binders in the v3 order judgment.
  • Add RED/GREEN witnesses: each of the three probes above must refuse, and a fresh Match binder must still lower and encode.
  • Update TIR-REQ-060 and its test-plan rows. Narrow or remove the "not Match-arm binders" caveat that PR #303 added to docs/topics/result-projections/README.md and crates/amblicit-syntax/src/result_projection/structured.rs.
  • Answer the String-scrutinee question: either file it separately, or show here that it is refused where it should be.

Exclusions

  • Flat v1/v2 lowering.
  • Result-projection source rules.
  • Provider behavior.

Acceptance

  • cargo test --locked -p amblicit-syntax --test target_ir, including the new cases.
  • cargo xtask verify.

Prerequisite

PR #303 must be merged first, because it adds the caveat this issue removes.

Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flyingrobots/edict

All issues in flyingrobots/edict

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.