Repository navigation
fix: run lines take their services from the container, as PHP# code does - #148
Merged
Merged
Conversation
…ne does Problem: section 29 makes creating a foreign object outside a module a compile error, and the environment example's run line does exactly that: new Deploy(new Environment()).target(). A run line is PHP#, and it is the only line sharp/bin/spec lets restate a throws on a method's line, so the example cannot keep its claim once the rule holds. Solution: check_reached also counts a running line of a plain PHP statements block of the same example as restating a claim. Plain PHP may create the object, so the section 29 PR moves the claim to such a block. The self-test gains restated-by-php, which stops the check when the rule is switched off. Every spec example passes or fails as before: 201 checked, 1 ignored, and the same 16 fail. sharp/ ├── bin/spec check_reached: a plain PHP line restates a claim └── spec-self-test.md restated-by-php docs/architecture/ └── spec-examples.md which lines restate a claim
Problem: spec section 29 makes creating a foreign object outside a module binding a compile error, and the environment example's run line does exactly that: new Deploy(new Environment()).target(). The previous commit moved the claim to a plain PHP block, which teaches a reader that making an Environment takes plain PHP. PHP# code gets a foreign object through its constructor, from a module binding. Solution: the plain PHP restatement is gone, so only a run line restates a claim again. A run line may declare the run class's constructor, and the run script fills each parameter from Sharp\Container, as the container fills a bound class's constructor. The script reads the standard library's module first, as its Composer autoload does, so `Environment` is bound. A run class with no constructor parameters is created as before. The self-test's run-takes-services gets a Gauge that holds an Environment through a module binding. Without the container fill its run reads an unset field, and without the module read the container finds no binding for Sharp\Environment. Every spec example passes or fails as before: 201 checked, 1 ignored, and the same 16 fail. sharp/ ├── bin/spec runner: run_entry fills a constructor from the container └── spec-self-test.md run-takes-services replaces restated-by-php docs/architecture/ └── spec-examples.md run lines reach a foreign object through a constructor
heyJordanParker
added a commit
that referenced
this pull request
Oct 16, 2026
The example showed its throws claim through a plain PHP block, which taught a reader that creating an Environment takes plain PHP. It now shows a module binding of Deploy, and its run lines take the Deploy through a constructor, as PR #148 lets a run do. With #148's runner and this branch's checker, the environment example passes and the same 16 examples fail.
heyJordanParker
added a commit
that referenced
this pull request
Oct 16, 2026
Master brings #142, #146, #147, #148 and #149. Each conflict keeps both sides' behavior: - A lambda's result type: master's `AnalysisArtifacts::lambda_result` is the one mechanism. `try` in a lambda reads it, and #143's `BlockContext::lambda_result_type` with its setters is gone. - A `match`'s declared type reaching its PHP and its arms: master's code, with `Expression::Match` kept in `takes_declared_type`, without which the PHP `match` takes no declared type. - `==` on a struct or a case: master's per-side type arguments for a generic struct, and a generic enum's case fields read the enum's type arguments from the side that gives them, through `with_type_arguments`. - A call's declared type: master's `declared_return_type` goes through `as_declared_ancestor`, so `Result.Ok(…)` into a `Result<int, E>` fixes the case's type arguments for the arguments and for the result. - The bridge: master's `generic_statics`, with `class_metadata` taking the class it describes, as a generic enum's case needs. - Spec section 11 keeps master's inference bullets and #143's rule for a static call of a generic class.
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.
Run lines get a
foreignobject the way PHP# code does: through a constructor, from a module binding. This lands ahead of the section 29 PR, becauseSPEC_GUARDjudges a PR with the base'ssharp/bin/spec.Problem
Section 29 makes creating a
foreignobject outside a module binding a compile error. Theenvironmentexample's run line does exactly that:The run class was always created without its constructor, so a run line had no way to get a
foreignobject exceptnew.What changes
sharp/bin/specfills the run class's constructor parameters fromSharp\Container, as the container fills a bound class's constructor. It reads the standard library's module first, as the library's Composer autoload does, soEnvironmentis bound. A run class with no constructor parameters is created as before.sharp/spec-self-test.mdgainsrun-takes-services: aGaugeholds anEnvironmentthrough a module binding, and its run lines declarepublic ExampleRun(private Gauge gauge) { }.docs/architecture/spec-examples.mdsays how run lines reach aforeignobject.The section 29 PR then shows the
environmentclaim with a visible module block and these run lines:Verification
Run on this branch, which starts at master
849232f4e1, with the engine andmagobuilt from that commit:sharp/bin/spec --self-test: 22 of 22 self-test examples give the problems they expect.sharp/bin/specon master: "Checked 201 examples, ignored 1, and 16 fail."sharp/bin/specon this branch: "Checked 201 examples, ignored 1, and 16 fail." The 16 are the same examples:§2 keyword-case,§7 variadic-parameters,§8 standard-library-calls,§8 output-and-exit,§9 parameter-member-limits,§11 generic-method-inference,§11 type-parameter-bounds,§18 template-to-string,§19 operators,§27 one-type-per-file,§27 position,§29 pure-interface,§29 function-effects,§31 result-enum,§31 try-propagation,§31 error-interface.