Repository navigation
fix: sharp/bin/spec gives each setup type of a named block a file of its own - #150
Merged
Merged
Conversation
…its own A block whose first line names its file, as `// app/Order.sharp`, was written as one file with its marker's setup, so required-constructors put the setup's DatabaseEntity in app/Order.sharp, which section 27's one-type rule refuses. split_types takes `$named`: a named block's file keeps every type the block writes a line of, as written, so one-type-per-file still shows its error, and each type the setup alone declares goes to the path its namespace and name give. sharp/spec-self-test.md gains named-file-setup.
heyJordanParker
added a commit
that referenced
this pull request
Oct 16, 2026
Problem #145 was behind master, which gained #142, #143, #144, #146 to #150. Both sides changed the default names: this branch generates them from the standard library into `SHARP_CLASSES`, and #143 added `Result` to a hand-written list and made `Error` a default name nothing shadows. Solution One mechanism: `default_classes()` stays `NAMED_EFFECTS` plus the generated `SHARP_CLASSES`, regenerated from the merged library, which now holds `Sharp\Error` and `Sharp\Result`. #143's `fixed_default_class` stays, and `default_classes()` leaves out the class it fixes, so `Error` is never shadowable while `Result` is. sharp/mago/crates/names/src/ ├── lib.rs default_classes and fixed_default_class ├── sharp_classes.rs regenerated: Error and Result join └── internal/walker.rs both imports kept docs/architecture/slices/23-names-imports.md Error is the one fixed default name
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:
sharp/bin/specwrites the types of a block's setup into the block's own file when the block names its file, so the one-type-per-file rule of section 27 will refuserequired-constructors, which passes today.This PR changes only the measure, as #147 did. The rule itself comes in the section 27 feature PR.
Problem
#147 gave each type of an example a file of its own, but only for a block that names no file. A block whose first line is a path comment, such as
// app/Order.sharp, stayed one file, with its marker's setup inside it.required-constructorsis that case: its setup declarespublic abstract class DatabaseEntity, and its block namesapp/Order.sharp. With the rule, its run reports:Solution
split_typestakes$named. A named block's file keeps every type the block writes a line of, as written, soone-type-per-filestill shows its error. Each type that only the setup declares goes to the path its namespace and name give, as every other generated file does. The named file is the first part, so it keeps the path and holds the run of a statements block.sharp/spec-self-test.mdgainsnamed-file-setup. Its setup declaresSeat, and its block namesapp/Ticket.sharp. An error inSeatnamesapp/Seat.sharp.docs/architecture/spec-examples.mdsays how a named block's setup types become files.Verification
Checked 202 examples, ignored 1, and 14 failbefore and after. The two full reports are byte for byte the same:diffof them prints nothing. Master fails 14, not 16, since feat: every rule of section 11, generics, compiles, refuses or runs as the spec says #142 madegeneric-method-inferenceandtype-parameter-boundspass. The 187 passing examples are below.sharp/bin/spec --self-testgives21 of 22 self-test examples give the problems they expect.named-file-setupfails there withreported, and not expected: line 4 of the generated app/Ticket.sharp, from the marker's setup or wrapper: Invalid return type for methodSeat.number: expectedint, but foundstring.On this branch it gives22 of 22.feat/files, which adds the one-type rule, this runner givesChecked 201 examples, ignored 1, and 14 fail.required-constructors,one-type-per-fileandpositionall pass.The 187 examples that pass, before and after