Repository navigation
fix: the spec check reads an => line under a signature and a bodyless declaration - #154
Merged
Merged
Conversation
…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
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.
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:sharp/bin/speccould not check it as written:=> this.gateway.charge(…);as a run statement of its own, and gave the signature above it{ … }.;ofmap, so the example class held a method with no body: "Non-Abstract methodExample.twicemust have a concrete body."So #136 laid the specimen out on one line per method and dropped
map's;.complete()also still held theusessignature rule, which serveduses f. Decision 79 replaceduses f, and the parser now refuses it.Solution
=>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 acompile errorline reads past it, so a signature whose=> …line it leaves out still gets{ … }.;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;.usessignature rule and itsuses-signatureself-test go.Verification
The two new self-test rows fail under master's
sharp/bin/specand pass under this one.bodyless-signatureunder master's copy: "line 1 expects no error, and the checker reports: Non-Abstract methodExample.twicemust have a concrete body."arrow-continuationunder master's copy: "line 2 expects no error, and the checker reports: Parse error encountered during parsing Unexpected tokenEqualGreaterThan."arrow-continuationfails again on line 2's parse errors and "line 4 expects a compile error, and the checker accepts it".7,arrow-continuationreports "line 5 expects 7, and gives 6", so its run line is compared.On macOS, with master's engine:
sharp/bin/spec --self-testgives 24 of 24.sharp/bin/test --specpasses 306 of 306 engine tests, and reports "Checked 204 examples, ignored 1, and 7 fail". Those 7 are the 7 entries ofsharp/baseline/spec, andfunction-effectspasses in its restored layout.sharp/bin/spec --base a280201144, the SPEC_GUARD check, reports "0 entries join sharp/baseline/spec, 0 leave it."Files