Repository navigation
Description
Summary
Needs a language-design split before implementation. The compiler and stdlib currently accept = as a trait/impl body introducer, while the specification's body grammar only allows :, indented :, and braces. The issue cannot be implemented correctly until the project chooses whether = is real syntax or legacy syntax to remove.
Spec
docs/with-specification.md:10991-11035 defines block body syntax for declarations and control forms. docs/with-specification.md:11365-11392 gives the expression grammar, and docs/with-specification.md:11430-11444 defines BODY := COLON_INLINE | COLON_INDENTED | BRACE_BODY. None of these include = as a declaration body introducer.
docs/requirements.md:11565-11620 mirrors that only the three body forms are required.
Current state
The parser explicitly accepts = for trait blocks: src/Parser.w:2506 starts parse_trait_decl, and src/Parser.w:2520-2524 accepts {, =, or :. Impl blocks do the same at src/Parser.w:2766-2768. Trait and impl methods inside those blocks still require : or {, with trait methods at src/Parser.w:2607-2614 and impl methods at src/Parser.w:2827-2834.
The stdlib relies on the accepted-but-unspecified syntax. Examples include pub trait Iter[T] = in lib/std/traits.w:48, other trait bodies in lib/std/traits.w:38-68, and impl[T] Iter[T] for VecIter[T] = in lib/std/collections.w:133. Tests also use it, for example test/spec/spec_ss13_2_iterator_borrowing.w:10.
docs/completed/spec-impl-unalignment.md:246 already records this as a spec/implementation mismatch.
Implementation plan
Phase 0 is the decision:
Track A, make = official: update docs/with-specification.md and docs/requirements.md so trait/impl declarations explicitly allow = as a declaration-body introducer, and add parser tests proving it is accepted only where intended.
Track B, remove legacy =: migrate stdlib and tests from trait/impl ... = to : or braces, then remove TK_EQ from parse_trait_decl and parse_impl_block. Add compile-error tests proving trait T = and impl T = now fail with a precise diagnostic.
Do not mix the tracks. If = remains accepted, the spec must say so. If the spec remains unchanged, the parser and stdlib must stop using it.
Test plan
For Track A, add spec/parser tests for trait T =, impl T =, trait T:, impl T:, and braced forms, then run the full suite.
For Track B, run a source grep for trait .*= and impl .*= after migration, add compile-error tests for the removed syntax, and run the full suite.
Acceptance criteria
- The spec, requirements, parser, stdlib, and tests agree on whether
=is valid. - There is at least one direct regression test for the chosen behavior.
- Error messages for the rejected form, if rejected, name the expected body introducers.
- No source file relies on syntax that the spec does not describe.
Dependencies
Needs a design decision. Related to #410 if the spec inventory gate is used to enforce the final grammar alignment.
Activity
ehartford commentedon Jun 10, 2026
Implemented in 129c4d1 (Remove legacy equals trait bodies). Chose Track B: migrated trait and impl declarations to colon bodies, removed parser acceptance of equals body introducers, updated render/parser fixtures, and added direct negative tests for trait equals and impl equals forms. Verification: explicit-seed build, fixpoint, full test, and test-green all passed.