fix(checker): unify implementation targets with a shared substitution and an occurs check #448
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/441-checker-overlap-occurs-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #441
What and why
reportOverlapaskedcouldUnifytwice, once for the targets and once for the trait applications, andcouldUnifywas stateless: every generic parameter unified with anything. SoTensor<Scalar> with Multiply<Scalar>besideextend<Scalar> Tensor<Scalar> with Multiply<Tensor<Scalar>, Tensor<Scalar>>was refused, althoughScalar = Tensor<Scalar>has no solution.couldUnifyis now a real unification over one substitution that is shared by the target pair and the trait pair:ParameterId(two entries of onewithlist);Wrapper<A, A>does not overlapWrapper<Int, String>, it does overlapWrapper<Int, Int>);Variable,InvalidandDeferredstay open, so there are no new false negatives and no cascade errors; the bound and blanket messages are untouched.Tests
compiler/tests/implementations.test.trb: the repro is accepted;Multiply<Scalar>besideMultiply<Int>on one generic type is still refused with the unchanged message; a parameter used twice is consistent (both directions). The existing overlap tests are unmodified.tests/language/overlap.trb(+.expected):a * 3.0,a * band(a * b) * 0.5on aTensor<Float>, run withtorb runandtorb run --nativeby the gate.torb check compiler(nightly toolchain) "no problems",torb formaton the three touched.trbfiles. Bootstrap, gates and the test suites run in forge CI.Seed
None: no syntax change, no new native, no driver flag, no name looked up by string. The checker only accepts more programs.
Docs:
docs/design/TENSOR.mdsection 7 (probe row and finding),CONCEPT.mdCoherence,docs/TYPECHECKER.mdOverlap. No page that feedsskills/changed.a7ce9cf106cb607946a2Multiply<Scalar>andMultiplyon one generic type are refused as overlapping #441Review of
cb60794. CI is green on this head, but the PR does not merge into currentmain.Findings
mainmoved tobc504c2(merge base is still7d4fe62) anddocs/design/TENSOR.mdconflicts. #440 rewrote the same section 7 lines this PR edits (the3.0 * tensorprobe row, thescalar * tensorfinding, and the lines near the #441 finding). Please rebase ontomainand resolve the conflict. Keep #440's wording of thescalar * tensorfinding and the(before #440)marker on the probe row, and apply the #441 changes on top. Then re-run the pdisc stamp forTENSOR.mdandCONCEPT.md, since the body hashes change with the rebase.Checked, no findings
unifyTermskeeps the two implementations' parameters apart throughvariableKey(parameter, side), and one substitution is shared by the target pair and the trait pair.bindVariableruns the occurs check throughoccursIn, which follows bound parameters, so the substitution cannot form a cycle.Variable,InvalidandDeferredstay open, so there are no new cascade errors. Theleft == rightshortcut is gone, but identical parameter-free types still compare equal in the fallback arm.Multiply<Int, ...>case with the unchanged message, and a parameter used twice in both directions.tests/language/overlap.trbruns through the gates. CI is green: bootstrap, tier A, tier B, gates, pdisc.No further changes are expected beyond the rebase. A re-review will check only the conflict resolution.
cb607946a2003eee4d5eRe-review of
003eee4(earlier round:cb60794, blocker was the conflict with main). CI is green on this head, including bootstrap, tier A, gates and pdisc.Earlier blocker
TENSOR.mdsection 7 edits sit on top of #440's wording (the(before #440)marker on the3.0 * tensorrow and the #440scalar * tensorfinding are kept). TheCONCEPT.mdstamp in.pdisc-sidecar.yamlwas refreshed and the pdisc check is green.Checked, no findings
variableKey(parameter, side), one substitution is shared by the target pair and the trait pair,bindVariableruns the occurs check throughoccursIn(which follows bound parameters), andVariable/Invalid/Deferredstay open. Expected values intests/language/overlap.expectedcheck out by hand.Multiply<Int, ...>case with the unchanged message, and a parameter used twice in both directions;tests/language/overlap.trbruns through the gates.Non-blocking
docs/design/TENSOR.md, the paragraph on the two things deliberately not promised: the rewritten*between two tensors sentence is one very long line (about 170 characters); rewrap when next touched.From<Scalar>on a generic type is refused as overlapping the blanketFrom<Never>#455