Repository navigation
Description
Summary
Add missing test coverage for trait coherence rules in §11.4 and sealed trait implementation restrictions in §11.6. The sema diagnostics exist; this issue should make them stable.
Spec
§11.4's orphan rule requires a local trait or local type for trait impls. §11.6 includes sealed traits, which may only be implemented in their defining module. §29.12 also gives E1101/E1102/E1201 slots for coherence diagnostics.
Current state
Orphan rule enforcement is implemented at src/SemaDecl.w:1569-1575. Sealed trait external-impl rejection is implemented at src/SemaDecl.w:1577-1581. Duplicate impl rejection is at src/SemaDecl.w:1710-1717, and overlap rejection is at src/SemaDecl.w:1547-1556. The requirements campaign notes the orphan and sealed paths are not directly covered by negative tests for 11.4.1.1 and 11.6.1.9.
Implementation plan
- Add compile-error fixtures for orphan impl and sealed trait impl outside the defining module.
- Add a positive sealed trait fixture showing an impl inside the defining module remains allowed.
- Share fixtures with Tests: coherence errors coverage (§29) #488 where possible: Tests: coherence errors coverage (§29) #488 is focused on §29 error-code coverage, while this issue should cover §11 trait semantics.
- If Emit spec'd diagnostic codes (E0901, E0951-3, E1101-2, E1201) (§29.12) #429 adds diagnostic codes first, assert codes; otherwise assert stable message substrings and leave a comment referencing Emit spec'd diagnostic codes (E0901, E0951-3, E1101-2, E1201) (§29.12) #429.
- Keep tests small and source-level; no codegen behavior is required.
Test plan
Add:
test/compile_errors/err_trait_orphan_impl_rule.wtest/compile_errors/err_sealed_trait_impl_outside_module.wtest/spec/spec_ss11_6_sealed_trait_local_impl.w
If not already covered, add duplicate/overlap fixtures or point #488 at them.
Acceptance criteria
- Orphan trait impl rejection has direct §11 coverage.
- Sealed trait external impl rejection has direct negative coverage.
- Allowed local sealed impl behavior is covered.
- Tests are coordinated with Tests: coherence errors coverage (§29) #488 and Emit spec'd diagnostic codes (E0901, E0951-3, E1101-2, E1201) (§29.12) #429 to avoid brittle duplicates.
with build && with build :fixpoint && with build :testpass.
Dependencies
#488 overlaps coherence diagnostic tests. #429 may add formal diagnostic codes. #435 expands coherence to extension methods but is separate.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 11.4.1.1, 11.6.1.9.
Activity
ehartford commentedon Jul 3, 2026
Covered by
test/compile_errors/err_orphan_rule_foreign_impl.w(foreign trait for foreign type →orphan rule violation ... [E1101], §11.4),test/compile_errors/err_sealed_trait_external_impl.w(§11.6 external sealed impl →cannot implement sealed trait ... outside its defining module), andtest/spec/spec_ss11_6_sealed_local_impl.w(allowed same-module sealed impl runs). Cross-module helpers live intest/compile_errors/lib/coherence/. Verified on HEAD; full gate green (native-compile-error-tests 681, native-spec-tests 206, GATES EXIT: 0).test: pin §29 string/block forms, §23.3 with control flow, §11 coherence
test: pin §11.4 coherence diagnostics + §29.8 no-shadowing rule