Skip to content

docs: the spec states Jordan's specimen rulings, no type nests, and 12 examples lose their bugs - #106

Merged
heyJordanParker merged 5 commits into
masterfrom
docs/specimen-rulings
Oct 12, 2026
Merged

heyJordanParker merged 5 commits into
masterfrom
docs/specimen-rulings

Conversation

@heyJordanParker

@heyJordanParker heyJordanParker commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Problem

  • The spec nested events and their interface inside the class that raises them, as Order.Paid and Order.Event, and many examples showed several types in one block. Jordan ruled that every type is declared in its own file in a namespace.
  • The spec didn't say:
    • what new Order.Paid(…) means when Order has a named constructor Paid,
    • whether extern event takes uses,
    • whether a PHP keyword PHP# doesn't use can name a local,
    • whether a change through an index sticks,
    • whether a body may go without braces,
    • whether a subclass constructor may skip : super(…),
    • whether : super(…) may read this,
    • whether a named constructor may set a get-only property again.
  • Twelve examples failed because the example itself had a bug, not because a feature was missing. A developer copying them got code that doesn't compile.

Solution

Jordan's rulings, written into the sections they belong to:

  • §27, one type per file: a .sharp file declares one type, named like the file, as Composer's PSR-4 autoloader loads one class per file. A second type in a file is a compile error. Example one-type-per-file.
  • §15, nothing nests: every type, events and interfaces included, is declared at file level in its own file (§27). event-declarations shows app/OrderEvent.sharp, app/OrderPaid.sharp, app/OrderRefunded.sharp, app/Order.sharp and app/Receipts.sharp, each with its namespace. "the way C# nests types" is gone. emit-forms, listeners, listener-errors, §24's naming-cases and §29's emit-effect use the file-level names.
  • §15, new Order.Paid(…): one sentence says it always calls Order's named constructor Paid, because . in code is always member access, and that §23 already refuses a type App.Order.Paid beside the class App.Order. It adds no new error.
  • §15, extern event JobFailed uses Database;: it states the class's effects, as §29's extern … uses does. extern event JobFailed; stays an event and pure. Example extern-event-effects.
  • §15, a nested type named like its class: this ruling is withdrawn, because nothing nests. The spec says nothing about it.
  • §28.1 is held. Jordan's approved @[rule] example writes bare names, and Mago takes quoted full names, so §28.1 stays as master has it until Jordan answers.
  • §2: a PHP keyword that PHP# doesn't use, such as empty, list or print, can name a local. Every keyword PHP# uses stays reserved. Example keyword-names.
  • §12: a List index is a place, as a Rust Vec index and a Go slice index are, so grid[0].add(5) changes the stored list. A change through a Map index is refused: "a Map read is a copy: read it, change it, and store it back". Example index-changes.
  • §17: the body of every if, else, while, do and for is written in braces, as in Go, Rust, Swift and PSR-12. Example braces.
  • §9.1, : super(…): a subclass constructor always calls its parent's with : super(…), even when the parent takes no arguments, as Kotlin always writes : Document(). Example super-call.
  • §9.1, this in a constructor call: this in the arguments of : super(…) or : this(…) is refused: "this is not available before the constructor runs: pass a parameter instead." Example constructor-call-this.
  • §9.1, get-only: a get-only property is set once, so a named constructor can't set one again. A property it sets again is declared { get; init; }, as §6.1 allows. Example set-once, with both Money.zero lines. The old bullet "A named constructor … can set get-only properties" is replaced.

Examples that now show each type's file

Each type is its own block with its path and namespace, and the statements that use them stay in a block of their own:

  • §9.1 super-call: Document.sharp, Invoice.sharp
  • §10 struct-changes: Point.sharp, Size.sharp
  • §12 enum-map-keys: Status.sharp, OrderStats.sharp
  • §13 readonly-fields: Invoice.sharp, Bill.sharp, Quote.sharp, Receipt.sharp
  • §15 event-declarations: OrderEvent.sharp, OrderPaid.sharp, OrderRefunded.sharp, Order.sharp, Receipts.sharp
  • §19 operators: DatabaseEntity.sharp, Money.sharp
  • §20.1 sealed-interfaces: Interaction.sharp, PopupInteraction.sharp
  • §22 virtual-methods: DatabaseEntity.sharp, Page.sharp
  • §22 override-parameter-names: Image.sharp, Thumbnail.sharp
  • §22 interface-defaults: HasDesign.sharp, Page.sharp
  • §22 plain-php-traits: Order.sharp, Draft.sharp
  • §24 naming-cases: Billing/Status.sharp, Billing/Invoice.sharp, Billing/InvoicePaid.sharp
  • §25 class-values: Element.sharp, FormBuilder.sharp
  • §25 required-constructors: Order.sharp, Invoice.sharp
  • §29 pure-interface: Formatter.sharp, Visitor.sharp, FileFormatter.sharp
  • §29 environment: Deploy.sharp, CheckoutController.sharp
  • §29 extern-implementations: AudienceSync.sharp, StripeGateway.sharp, MailchimpSync.sharp. The imports that were hidden setup are now in the files that use them.
  • §29 emit-effect: OrderPaid.sharp, Checkout.sharp, StoreCheckout.sharp. The event that was hidden setup is now its own file.
  • §31 error-interface: the standard library's Error, and PaymentError.sharp

Braceless bodies that gained braces

  • §9 parameter-members: if (!tenant.active) throw new InactiveTenant(tenant); became if (!tenant.active) { throw new InactiveTenant(tenant); }.
  • §14.2 lambdas: if (line.free) return Money.zero(currency); became if (line.free) { return Money.zero(currency); }.

No other if, else, while, do or for body in docs/spec.md or README.md was missing braces.

The twelve example fixes

Each fix changes the example only, never the rule it shows. These fixes needed more than the line named:

  • §19 operators: DatabaseEntity declares Jordan's public int id { get; }, set by its constructor, public DatabaseEntity(int id) { this.id = id; }, and the setup creates new Order(1). It stays on the list: the shared Order has no constructor that calls : super(id), so the run throws "Typed property App\DatabaseEntity::$id must not be accessed before initialization". It passes once : super(…) reaches the pinned Mago and the shared Order calls it.
  • §19 lifted-equality: the next line, total == Money.zero, had the same bug, so it also became Money.zero("USD"). Its annotation became // false: total is a Money, …, because a bare comparison whose annotation names no value is refused as "This statement has no effect".
  • §21 match-forms: Log.info is Laravel's facade, so the marker's hidden setup imports Illuminate.Support.Facades.Log, as §25's typeof-values does.
  • §21 is-not-scope and §14.4 leave-on-null: this.prices and this.customers need declared fields. They are hidden setup lines, private Map<string, int> prices = [:]; and private Map<int, Customer> customers = [:];, as §14.4's needless-null-checks declares its field.
  • §21 property-narrowing: the line above gained one space so the two comments stay aligned.
  • §15 scoped-listener: the fields are constructor parameters, public ImportScreen(private ProgressBar progress, private Importer importer) { } (§9). The marker's shape became members, and its hidden setup declares ProgressBar and Importer, which the harness lacks.
  • §26 extensions: TextExtensions.sharp is in App.Shared.Text, so it imports Illuminate.Support.Str, as §14.3 does. The string title setup moved to the second block.

The list

sharp/baseline/spec goes from 96 to 100 entries.

These four leave, because they now pass:

  • §19 lifted-equality
  • §21 is-not-scope
  • §21 property-narrowing
  • §24 any-checks

These eight join. Each is a new example for a ruling that isn't built yet:

  • §2 keyword-names: the checker accepts const match = 1;.
  • §9.1 constructor-call-this: a named constructor is "not supported yet".
  • §9.1 set-once: a named constructor is "not supported yet".
  • §9.1 super-call: : super() is a parse error, and a constructor without it compiles.
  • §12 index-changes: grid[0].add(5) is refused with "This method changes the collection, which has no place to be written back to."
  • §15 extern-event-effects: extern event is a parse error.
  • §17 braces: a braceless body is "not supported yet", which doesn't count as the compile error.
  • §27 one-type-per-file: a second type in a file compiles.

These fixed examples stay listed, because a feature they use isn't built yet:

  • §6 field-and-property: internal set is a parse error.
  • §14.4 leave-on-null: ?? return and ?? continue are parse errors.
  • §15 event-declarations: event declarations are parse errors.
  • §15 scoped-listener: Events.on<RowImported>(…) is read as a chained comparison. The harness also has no App.Imports.RowImported.
  • §19 operators: the shared Order doesn't call : super(id), as above.
  • §21 match-forms: an enum case pattern with data is "not supported yet".
  • §26 extensions: extension(string value) is a parse error.
  • §28 state-machine-law: "Law refundedIsFinal is not proven: Mago did not translate Payment, which the law reaches."

Files

docs/
└── spec.md               # rulings in §2, §9.1, §12, §15, §17, §27; braces in §9, §14.2; every type in its own file; 12 example fixes
sharp/
└── baseline/spec         # 4 passing examples leave, 8 new examples join

… lose their bugs

Problem

- The spec didn't say what `new Order.Paid(…)` means when `Order` has both a
  nested type and a named constructor named `Paid`, whether `extern event` takes
  `uses`, whether a class may nest a type with its own name, or how a Lean
  structure rule is written.
- Twelve examples failed because the example itself had a bug, not because a
  feature was missing, so a developer copying them got code that doesn't
  compile.

Solution

- §15: `new Order.Paid(…)` creates the nested type when `Order` declares one,
  and calls the named constructor `Paid` otherwise. Declaring both is a compile
  error. A class can't nest a type with its own name (C# CS0542).
  `extern event JobFailed uses Database;` states the class's effects, and
  `extern event JobFailed;` stays pure.
- §28.1: a structure rule is a Lean definition with `@[rule]`, as in
  `@[rule] def importsOnly : Rule := .importsOnly [Billing.Money, Shared]`.
- The twelve examples carry their fixes, each rule unchanged. lifted-equality,
  is-not-scope, property-narrowing and any-checks now pass and leave
  sharp/baseline/spec. The four new §15 examples join it until events and
  named constructors are built.

docs/
└── spec.md               # §15 rulings and 4 examples, §28.1 @[rule] bullet, 12 example fixes
sharp/
└── baseline/spec         # -4 passing examples, +4 new §15 examples
Problem

- The spec nested events and their interface inside the class that raises
  them, as `Order.Paid` and `Order.Event`. Jordan ruled that nothing nests, so
  a reader finds every type by its namespace and file, as in PHP.
- The spec didn't say whether a PHP keyword PHP# doesn't use can name a
  local, whether a change through an index sticks, whether a body may go
  without braces, whether a subclass constructor may skip `: super(…)`,
  whether `: super(…)` may read `this`, or whether a named constructor may
  set a get-only property again.

Solution

- §15: every event and event interface is its own file at file level, as
  `app/OrderPaid.sharp` declares `OrderPaid`. Listeners, `emit` and §24's and
  §29's examples use the file-level names. `new Order.Paid(…)` always calls the
  named constructor, and a type in the namespace `App.Order` beside the class
  `App.Order` is §23's compile error. The nested-type-named-like-its-class
  rule is gone, because nothing nests.
- §2: `empty`, `list` and `print` can name a local, and PHP#'s keywords stay
  reserved.
- §12: a `List` index is a place, and a change through a `Map` index is
  refused: "a Map read is a copy: read it, change it, and store it back".
- §17: every `if`, `else`, `while`, `do` and `for` body is in braces. The two
  braceless guards in §9 and §14.2 gained them.
- §9.1: a subclass constructor always writes `: super(…)`, `this` is refused
  in `: super(…)` and `: this(…)`, and a get-only property is set once, so a
  named constructor sets again only a `{ get; init; }` property.

docs/
└── spec.md               # §2, §9.1, §12, §15, §17 rulings; §9, §14.2 braces; §24, §29 file-level events
sharp/
└── baseline/spec         # the 7 new examples join, and §15's entries follow its renamed examples
@heyJordanParker heyJordanParker changed the title docs: the spec states Jordan's §15 and §28.1 rulings, and 12 examples lose their bugs docs: the spec states Jordan's specimen rulings, no type nests, and 12 examples lose their bugs Oct 12, 2026
…ng 1 in one sentence

Problem

- §19 operators declared a get-only `id` that nothing set, so its run threw
  "Typed property App\DatabaseEntity::$id must not be accessed before
  initialization".
- The §28.1 `@[rule]` line writes bare names, and Mago takes quoted full
  names. Jordan hasn't settled which form wins.
- §15 showed ruling 1 with an example of §23's existing error, and the
  answer needs one sentence and no new error.

Solution

- §19 operators declares `public int id { get; set; } = 1;`, as the shared
  `DatabaseEntity` does, so the example runs and leaves the list.
- §28.1's text is master's again.
- §15 says in one sentence that `new Order.Paid(…)` always calls the named
  constructor, and that §23 already refuses a type `App.Order.Paid` beside the
  class `App.Order`. The event-beside-class example is gone.

docs/
└── spec.md               # §15 ruling 1 sentence, §19 operators id, §28.1 as master
sharp/
└── baseline/spec         # operators leaves
…ype's file

Problem

- Jordan ruled that every type is declared in its own file in a namespace,
  as Composer's PSR-4 autoloader loads one class per file. The spec said it
  only in §15, and 18 examples outside §15 showed two or more types in one
  block, so a reader copied files the rule forbids.
- §12 said `points[0].x = 5` sets `x` on the stored point. No type makes that
  true: a struct never changes, and a class instance in a List is shared.
- §19 operators set `id` with `{ get; set; } = 1`, which changes the rule
  Jordan's fix shows.

Solution

- §27 states the rule once: a `.sharp` file declares one type, named like the
  file, and a second type is a compile error. §15 points to it.
- Every example that showed several types shows each type in its own block,
  with its path and namespace, as §15's event-declarations does. Statements
  stay in a block of their own.
- §12's index rule keeps `grid[0].add(5)` and drops `points[0].x = 5`.
- §19 operators declares `public int id { get; }`, set by
  `DatabaseEntity`'s constructor. It stays on the list until the shared
  `Order` calls `: super(…)`, which the pinned Mago doesn't parse yet.

docs/
└── spec.md               # §27 one-type rule; 18 examples split into files; §12 prose; §19 operators
sharp/
└── baseline/spec         # operators and one-type-per-file join
Problem

- §9.1 says there is no overloading by argument types, yet super-call gave
  `Invoice` two constructors and set-once gave `Money` two `Money.zero` named
  constructors. A reader learned that a second one is fine, and once the
  checker refuses duplicates, the error line could pass on that error instead
  of the rule it shows.

Solution

- super-call refuses the missing `: super()` in a second subclass,
  `app/CreditNote.sharp`, so `Invoice` keeps one constructor.
- set-once names the refused named constructor `Money.free`.
- Neither example needs `alone` now, because every line is valid beside the
  others except the one error it marks.

docs/
└── spec.md               # §9.1 super-call and set-once
@heyJordanParker
heyJordanParker merged commit 2480a9e into master Oct 12, 2026
12 checks passed
heyJordanParker added a commit that referenced this pull request Oct 12, 2026
Problem: master moved 8 commits past the branch: the #106 spec rulings and the
#107 merge. The branch's sharp/bin/build and sharp/bin/census already match
master, but its docs/spec.md and sharp/baseline/spec do not.

Solution: merge origin/master with no rebase. docs/spec.md merged cleanly.
sharp/baseline/spec conflicted on the two examples master added as failing,
§12 index-changes and §12 index-rules, which the branch's baseline lacked. The
merge keeps both lines. The re-pin's spec run decides whether they still fail.

docs/spec.md          master's rulings, merged without conflict
sharp/baseline/spec   master's two new §12 lines kept
@heyJordanParker
heyJordanParker deleted the docs/specimen-rulings 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