Repository navigation
Parser: trait/impl/extend bodies take exactly the three §29.13 body forms - #1357
Merged
ehartford merged 1 commit intoSep 23, 2026
Merged
Conversation
…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
changed the base branch from
repair-scrambled-trait-headers
to
fix-1349-tuple-pattern-if-subject
September 23, 2026 01:03
ehartford
force-pushed
the
fix-1349-tuple-pattern-if-subject
branch
from
September 23, 2026 01:03
7e2fff1 to
3786a9c
Compare
ehartford
force-pushed
the
fix-1346-trait-impl-body-forms
branch
from
September 23, 2026 01:03
7aff486 to
16f97a3
Compare
Contributor
Author
|
Batch battery (seed-driven) on main dd786a4 + #1355 → #1357 → #1370 → #1371 as one linear chain (head 45f8aa4): build ok, :fixpoint ok, :test ok (no reds), :test-green ok, :last-green ok. The four PRs are now stacked exactly as tested (each branch = its commit on top of the previous PR); merge in order #1355, #1357, #1370, #1371, retargeting each to main as its parent merges. |
ehartford
marked this pull request as ready for review
September 23, 2026 01:03
This was referenced Sep 23, 2026
This was referenced Sep 23, 2026
ehartford
added a commit
that referenced
this pull request
Sep 23, 2026
…nd-chained bases (#1436) Hand-chained bases stranded #1357 in a dead branch, and squash-merging the top of a cumulative chain (#1360) landed five PRs as one commit (2026-09-22). gh stack link creates the stack from staging-worktree branches without local tracking; gh stack merge lands it all-or-nothing in order; gh stack rebase replays merged parents with --onto. Co-authored-by: Eric Hartford <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1346. Stacked on #1347 (which repairs the 45 files that a bad rewrite scrambled into the rejected shape).
What changed
src/Parser.wparse_trait_declandparse_impl_blocknow pick the body form once, inparse_decl_body_introducer, and find member boundaries throughdecl_member_continues. Before, they skipped newlines after:and took members until one started at column 0.src/Lexer.wgainsline_indent_of.:then contentan inline trait body is a single member: it ended at the end of the header line, so this member is outside it (§29.13), with the helpend the line after \trait Foo:` and indent the first member like the rest, one member per line`:ends the lineexpected an indented trait body after ':', the same rule asfn f:{ }impl Foo for X(§2.3)\`impl Foo for X\` has no ':' or '{', so it is a bodyless impl that ends at its newline; the indented lines below it are not its members (§29.13), with the helpadd ':' to the end of the header to make them its body: `impl Foo for X:`expected ':' or '{' after the impl header(before, this fell through with no error)Tests
err_trait_inline_body_then_indented_members,err_impl_inline_body_then_indented_members,err_impl_bodyless_then_indented_members,err_trait_colon_without_indented_body,err_impl_header_trailing_tokensbehav_1346_trait_impl_body_forms. It covers inline single-member traits and impls, including a parameter list split across lines inside the parentheses, Form 2, braced bodies with;, an empty{}body, and a bodyless marker impl.err_trait_eq_body_removedanderr_impl_eq_body_removedstill match.Sweep
I parsed every
.wfile under src, lib, rt, tools, test, examples, build and build.w (3204 files) withast, once with the installed compiler and once with this stage1. No file uses a shape this change rejects. Every file whose result changed falls into one of two groups:rt/fiber_core_windows.whit the sweep's 30 s timeout under stage1 but passes given more time: theastrenderer is slow on large files, and parsing is not the problem. No UAT fixture or example was touched.Iterate tier only (
:devplus targeted fixtures). Draft until the seed-driven battery is posted.