Repository navigation
fix: a spec example finds an interface's Defaults trait in the interface's file - #137
Merged
Merged
Conversation
…ace's file A PHP# interface with default bodies compiles to the interface and the trait `<Interface>\Defaults`, both in the interface's file, spec section 22. PHP links a class's traits before its interfaces, so a class that implements the interface asks the autoloader for `App\HasDesign\Defaults` first. sharp/bin/spec mapped only the names a file declares at its top level, so that lookup found nothing and the example could never pass. declared_names() now also lists `<Interface>\Defaults` for each PHP# interface a file declares, and the runner's autoloader reads a file with require_once, since the trait and the interface now name one file. This is the change sharp/composer/autoload.php makes for an app in #133. The section 22 examples that use it run in #133, whose compiler builds default bodies. Master's compiler refuses them, so no self-test example can show the rule before #133 lands. sharp/ └── bin/spec declared_names lists X\Defaults, the autoloader uses require_once
heyJordanParker
added a commit
that referenced
this pull request
Oct 15, 2026
Two conflicts. The semantics checker runs master's `check_method_modifiers` beside `check_abstract_access` and `check_iterator_returns`. The bridge keeps master's `method_declaration`, which an interface's `signature` shares, with this branch's `private` default for a method with no access modifier and the PHP# callee its parent constructor call checks lazy sources against. Master's `super_of_call` passes its PHP# callee to `call` too, and two of master's bridge tests show the result type a method with no function type now carries.
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
A PHP# interface with default bodies compiles to the interface and the trait
<Interface>\Defaults, both in the interface's file. PHP links a class's traits before its interfaces, so a spec example's class that implements the interface asks the autoloader forApp\HasDesign\Defaultsfirst.sharp/bin/specmapped only the names a file declares at its top level, so the lookup found nothing and section 22'sinterface-defaultsexample could never pass.Solution
declared_names()also lists<Interface>\Defaultsfor each PHP# interface a file declares. The runner's autoloader reads a file withrequire_once, since the trait and the interface now name one file.sharp/composer/autoload.phpmakes the same change for an app in #133.SPEC_GUARD requires a change to
sharp/bin/specin a PR of its own, so this lands ahead of #133. The section 22 examples that use it run in #133, whose compiler builds default bodies. Master's compiler refuses them, so no self-test example can show the rule before #133 lands.Verification
sharp/bin/spec --self-test: 18 of 18 self-test examples give the problems they expect.sharp/bin/specwith master's mago: "Checked 197 examples, ignored 1, and 34 fail", equal tosharp/baseline/spec.sharp/bin/spec --base origin/master: "0 entries join sharp/baseline/spec, 0 leave it."sharp/bin/spec: "Checked 199 examples, ignored 1, and 32 fail", and--completesfor section 22: "§22: all 9 checked examples pass."