Skip to content

fix: the spec check reads an => line under a signature and a bodyless declaration - #154

Merged
heyJordanParker merged 1 commit into
masterfrom
fix/spec-reader
Oct 16, 2026
Merged

heyJordanParker merged 1 commit into
masterfrom
fix/spec-reader

Conversation

@heyJordanParker

Copy link
Copy Markdown
Owner

Problem

Section 29's specimen, as Jordan approved it, writes a library declaration with its ; and puts each method's => body on the line under its signature:

public List<TResult> map<TResult>(Function<TResult(T)> f);          // map takes on the effects of the f it calls

public Charge charge(Cart cart, Function<Cart(Cart)> prepare)
    => this.gateway.charge(prepare(cart));                            // Http, plus prepare's effects

sharp/bin/spec could not check it as written:

  • It read => this.gateway.charge(…); as a run statement of its own, and gave the signature above it { … }.
  • It kept the ; of map, so the example class held a method with no body: "Non-Abstract method Example.twice must have a concrete body."

So #136 laid the specimen out on one line per method and dropped map's ;. complete() also still held the uses signature rule, which served uses f. Decision 79 replaced uses f, and the parser now refuses it.

Solution

  • An => line continues its construct, as a line that starts with { or : does. A line runs where the line that starts its construct runs, both when the files are built and when a run's claims are compared. A run that leaves out a compile error line reads past it, so a signature whose => … line it leaves out still gets { … }.
  • A method declaration with modifiers, its ; and no body gets { … }, since a class holds no method without one. A field, an abstract method, an event and a method with an => body keep their ;.
  • The uses signature rule and its uses-signature self-test go.
  • Section 29's specimen gets its layout back.

Verification

The two new self-test rows fail under master's sharp/bin/spec and pass under this one.

  • bodyless-signature under master's copy: "line 1 expects no error, and the checker reports: Non-Abstract method Example.twice must have a concrete body."
  • arrow-continuation under master's copy: "line 2 expects no error, and the checker reports: Parse error encountered during parsing Unexpected token EqualGreaterThan."
  • With only the construct rule for runs taken back out, arrow-continuation fails again on line 2's parse errors and "line 4 expects a compile error, and the checker accepts it".
  • With its claim changed to 7, arrow-continuation reports "line 5 expects 7, and gives 6", so its run line is compared.

On macOS, with master's engine:

  • sharp/bin/spec --self-test gives 24 of 24.
  • sharp/bin/test --spec passes 306 of 306 engine tests, and reports "Checked 204 examples, ignored 1, and 7 fail". Those 7 are the 7 entries of sharp/baseline/spec, and function-effects passes in its restored layout.
  • Master's copy of sharp/bin/spec --base a280201144, the SPEC_GUARD check, reports "0 entries join sharp/baseline/spec, 0 leave it."

Files

docs/
├── spec.md                         <- section 29's specimen in its approved layout
└── architecture/spec-examples.md   <- the `=>` continuation and bodyless declarations
sharp/
├── bin/spec                        <- reads both, drops the `uses` signature rule
└── spec-self-test.md               <- bodyless-signature and arrow-continuation replace uses-signature

…ss declaration

Problem
- Section 29's specimen, the one Jordan approved, could not be checked as
  written. sharp/bin/spec read `    => this.gateway.charge(…);` as a run
  statement of its own and gave the signature above it `{ … }`. It kept
  the `;` of `public List<TResult> map<TResult>(Function<TResult(T)> f);`,
  so the class held a method with no body. #136 laid the specimen out on
  one line per method and dropped the `;` to pass.
- complete() still held the `uses` signature rule, which served `uses f`.
  Decision 79 replaced `uses f`, and the parser now refuses it.

Solution
- read_block continues a construct on a line that starts with `=>`, as it
  does on `{` and `:`. A line runs where the line that starts its
  construct runs, in build_files and in runs(). A run that leaves out a
  `compile error` line reads past it, so its signature still gets
  `{ … }`.
- complete() drops the `;` of a method declaration with modifiers and no
  body, so it gets `{ … }`. A field, an abstract method, an event and a
  method with an `=>` body keep their `;`.
- The `uses` signature rule and its uses-signature self-test go.
- New self-test rows bodyless-signature and arrow-continuation. Each
  failed under master's sharp/bin/spec.
- docs/spec.md section 29 gets the specimen's layout back.
- docs/architecture/spec-examples.md describes both rules.

docs
├── spec.md                         the specimen's layout restored
└── architecture/spec-examples.md   the `=>` continuation and bodyless declarations
sharp
├── bin/spec                        reads both, drops the `uses` rule
└── spec-self-test.md               bodyless-signature, arrow-continuation
@heyJordanParker
heyJordanParker merged commit bda1b92 into master Oct 16, 2026
22 checks passed
@heyJordanParker
heyJordanParker deleted the fix/spec-reader branch November 3, 2026 22:08
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.

1 participant