Repository navigation
Description
Summary
Add targeted derive tests for behavior that exists but is not regression-protected. This issue is test-only unless the new tests expose a mismatch with §11.8.
Spec
§11.8 says derive(all) derives every eligible trait the type qualifies for, but does not infer Copy for aggregates. It also allows derive requests where ineligible traits are skipped by design in specific conservative cases instead of producing an error.
Current state
The main derive spec test covers common positive behavior: Eq, Hash, Debug, Clone, Default, derive(all), and explicit Copy at test/spec/spec_ss11_8_derive.w:3-78. Builder coverage exists at test/spec/spec_ss11_8_derive_builder.w:3-40. The requirements campaign still found missing tests for 11.8.1.15 and 11.8.1.16: the silent-skip path and the “no error by design” path.
#409 owns implementation gaps such as Ord, enum Display, and user-defined derives. This issue should not duplicate that implementation work.
Implementation plan
- Identify the exact current derive paths that intentionally skip instead of erroring, likely in
ComptimeTransform.wderive generation and sema derive validation. - Add positive tests that assert skipped traits are absent via
comptime T.implements(Trait)and that compilation succeeds. - Add negative tests only for cases the spec says must error, such as explicit
@[derive(Copy)]with a non-Copy field. - Keep these tests independent of Complete derive targets: Default, Hash, Ord, Display, derive(all), derive(Builder) (§11.8) #409's unimplemented
Ord/Displaytargets unless Complete derive targets: Default, Hash, Ord, Display, derive(all), derive(Builder) (§11.8) #409 lands first. - Update test names to state the rule, not the implementation accident.
Test plan
Add test/spec/spec_ss11_8_derive_skip_semantics.w:
@[derive(all)]on a type with a non-Default or non-Hash field skips only the ineligible trait if that is current/spec behavior.@[derive(all)]never makes the typeCopy.- Explicit eligible derives still work on the same type.
Add/verify compile-error cases:
- explicit
@[derive(Copy)]on non-Copy field - explicit derive of a target whose required field method is missing, if §11.8 requires an error rather than skip.
Acceptance criteria
- Silent-skip/no-error derive behavior has direct tests.
- Tests distinguish
derive(all)conservative behavior from explicit derive failures. - Complete derive targets: Default, Hash, Ord, Display, derive(all), derive(Builder) (§11.8) #409 remains the implementation issue for missing derive targets.
with build && with build :fixpoint && with build :testpass.
Dependencies
#409 may change the exact eligible target list; land this after or coordinate expected outcomes.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 11.8.1.15, 11.8.1.16.
Activity
ehartford commentedon Jul 3, 2026
Closing — derive(all) derives eligible traits and silently skips ineligible ones (Default here) without inferring Copy, and derive(Copy) on non-Copy fields is rejected: spec_ss11_8_derive_skip + err_derive_copy_noncopy (ec03406). §11.8.1.15/16.
test: coverage-sweep batch 2 (#483 #484 #522 #493 #494 #514 #515 #532)