Repository navigation
fix: a spec example passes only on a rule the checker has, and runs an enum's data cases - #171
Merged
Merged
Conversation
…n enum's data cases Problem - A `compile error` line passes when the checker reports any error on it, a refusal that says "not supported yet" aside. #166 makes the checker's fallback for a construct no rule catches say "This … is not part of PHP#." That message would satisfy a `compile error` line, so a spec rule with no refusal of its own would pass the spec check. - The run's class map lists only the types a file declares at its top level. An enum whose cases carry data compiles each case to a class of its own, `App\Badge\Marked`, so a run that builds a case threw `Class "App\Badge\Marked" not found`. Solution - `GENERIC_REFUSAL`, beside `REFUSAL` in `check_compile`, keeps "This … is not part of PHP#." from satisfying a `compile error` line. The specific refusals, such as "`global` is not part of PHP#.", start otherwise and still satisfy one. - `declared_names` adds `Enum\Case` for every case of an enum whose cases carry data, plain cases too, as the bridge's `data_enum` makes a class of each. sharp/bin/ └── spec GENERIC_REFUSAL in check_compile, and the cases in declared_names
heyJordanParker
added a commit
that referenced
this pull request
Oct 18, 2026
…d beside the permanent refusals Problem #159, #165, #168, #170 and #171 landed on master. #159 gives attributes to interfaces, events, constants, accessors and lambdas, #168 gives every pattern type a test, and the collections work builds tuple and `Iterable` constants. #166's refusals of those forms as "not supported yet" are now refusals of code that compiles. `==` on an `Iterable` was still "not supported yet", and a `.sharp` file the engine refused stayed in PHP's included files, so a second `require_once` skipped it and a later use said "Class not found". Solution The merge keeps master's attribute arms, its `as` arm and its attribute-argument refusal, keeps `report_accessor` with #159's observer-attribute arm and its `ACCESSORS` note, and drops the arms master made unreachable: `is_undecided`'s attribute lists, pattern types with no test and tuple constants. `==` on an `Iterable`, or on a type parameter bound by a collection, is a permanent error that names `toList()`: "`==` compares a `List`, a `Map` or a `Set`, and an `Iterable` is none of them: compare `a.toList() == b.toList()`." A search and a struct property say the same. A `.sharp` file the engine refuses leaves PHP's included files, so a second `require_once` reports the same refusal. Spec section 20's `case-set-field` states its result, `// true`, which the spec tool now runs. php-sharp/ ├── Zend/tests/sharp/refusal_required_again.phpt a refused file is required again ├── docs/spec.md case-set-field gives true ├── ext/sharp/sharp.c sharp_compile_file drops a refused file └── sharp/mago/crates/ ├── analyzer/ │ ├── src/expression/binary/comparison.rs `==` on an Iterable names toList() │ └── tests/sharp.rs its rows, and a row that compiles toList() ├── hir/src/lower/error/mod.rs both sides' error list └── semantics/ ├── src/internal/checker/sharp.rs is_undecided, report_accessor, the as arm └── tests/sharp.rs rows for what master builds
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
compile errorline passes when the checker reports any error on it, except a "not supported yet" refusal. fix: a PHP form PHP# never has is refused for good, with what PHP# writes instead #166 makes the checker's fallback for a construct no rule catches say "This … is not part of PHP#." That message would satisfy acompile errorline. So a spec rule with no refusal of its own would pass the spec check.App\Badge\Marked. A run that builds a case throwsClass "App\Badge\Marked" not found.Solution
GENERIC_REFUSAL, besideREFUSALincheck_compile, keeps "This … is not part of PHP#." from satisfying acompile errorline. The specific refusals, such as "globalis not part of PHP#.", start otherwise and still satisfy one.declared_namesaddsEnum\Casefor every case of an enum whose cases carry data. Plain cases are included, because the bridge'sdata_enummakes a class of each case.This PR changes only
sharp/bin/spec. Master's checker never writes "This … is not part of PHP#.", so a self-test example of the new rule passes only on #166's checker. That example lands with #166.Verification
sharp/bin/spec --self-teston master's checker: 24 of 24.sharp/bin/spec: Checked 221 examples, ignored 1, and 0 fail.sharp/bin/spec --base origin/masteron this branch: 0 entries join sharp/baseline/spec, 0 leave it.Badge.Marked(["vip", "new"])and compared it. Before:the run threw Error: Class "App\Badge\Marked" not found. After: the run gavetruefor the same case andfalseforBadge.Blank.