Skip to content

Parser: trait/impl/extend bodies take exactly the three §29.13 body forms (#1346) — re-land of #1357 onto main - #1400

Merged
ehartford merged 1 commit into
mainfrom
fix-1346-trait-impl-body-forms
Sep 23, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-1346-trait-impl-body-forms

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Re-land of #1357. #1357 was stacked on #1355's branch and merged into that branch after #1355 had already merged, so its commit never reached main (parse_decl_body_introducer is absent from origin/main 00408eb). Same commit (16f97a3), tested in the batch battery on dd786a4 with #1355/#1370/#1371 (all green; see #1357). The branch also carries #1355's pre-squash commit 3786a9c, whose content is already on main as 1f4636d — identical changes, so the merge is clean and the net diff is #1346 alone.

Fixes #1346

@ehartford
ehartford force-pushed the fix-1346-trait-impl-body-forms branch from 16f97a3 to 194d7e1 Compare September 23, 2026 01:54
@ehartford
ehartford marked this pull request as draft September 23, 2026 01:56
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery (seed-driven) on main 00408eb + #1400 → #1370 → #1371 → #1397 as one chain (head 37a2441): build ok, :fixpoint ok, :test ok (no reds), :test-green ok, :last-green ok. Each branch holds exactly its tested commit on top of the previous PR's; all target main. Merge in order #1400, #1370, #1371, #1397.

…orms (#1346)

parse_trait_decl and parse_impl_block treated ':' as optional punctuation,
skipped newlines, and collected members until one started at column 0, so
an inline first member followed by indented members was one body, and a
bodyless `impl Foo for X` (§2.3) swallowed the indented `fn` lines after it.

Both now name the body form once (parse_decl_body_introducer) and read
member boundaries from it (decl_member_continues):
- Form 1 (':' then content): one member; a second is reported
  ("an inline trait body is a single member ...", fix-it: end the line
  after the header and indent the first member). Newlines inside the
  member's parentheses stay part of it.
- Form 2 (':' ends the line): members indented deeper than the header
  line; nothing indented below is "expected an indented trait body
  after ':'", as for `fn f:`.
- Form 3 (braces): members separated by newlines or semicolons
  (semicolons were rejected before).
- impl/extend with no introducer is bodyless and ends at its newline;
  indented lines after it are reported with the fix-it `impl Foo for X:`.
  Any other token after an impl header is "expected ':' or '{' after
  the impl header" (it used to fall through silently).

Sweep: every .w under src lib rt tools test examples build build.w
parsed with the installed compiler and this stage1; no file changes
verdict except the new fixtures and files that use syntax newer than
the installed compiler.

(cherry picked from commit 7aff486)
(cherry picked from commit 225ea6ed80a74de2a10e312b4fc7e91d61cde028)
@ehartford
ehartford force-pushed the fix-1346-trait-impl-body-forms branch from 194d7e1 to a1e3926 Compare September 23, 2026 02:56
@ehartford
ehartford merged commit cd40b15 into main Sep 23, 2026
@ehartford
ehartford deleted the fix-1346-trait-impl-body-forms branch September 24, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser: trait/impl body mixes an inline first member with indented members; a bodyless impl swallows the indented fns after it (§29.13)

1 participant