Skip to content

fix: a spec example passes only on a rule the checker has, and runs an enum's data cases - #171

Merged
heyJordanParker merged 2 commits into
masterfrom
fix/spec-refusal-check
Oct 18, 2026
Merged

heyJordanParker merged 2 commits into
masterfrom
fix/spec-refusal-check

Conversation

@heyJordanParker

Copy link
Copy Markdown
Owner

Problem

  • A compile error line 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 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 its own class, App\Badge\Marked. A run that builds a case throws 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 are included, because the bridge's data_enum makes 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-test on master's checker: 24 of 24.
  • sharp/bin/spec: Checked 221 examples, ignored 1, and 0 fail.
  • Master's sharp/bin/spec --base origin/master on this branch: 0 entries join sharp/baseline/spec, 0 leave it.
  • A local example built Badge.Marked(["vip", "new"]) and compared it. Before: the run threw Error: Class "App\Badge\Marked" not found. After: the run gave true for the same case and false for Badge.Blank.

…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
heyJordanParker merged commit fa16971 into master Oct 18, 2026
23 checks passed
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
@heyJordanParker
heyJordanParker deleted the fix/spec-refusal-check 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