Repository navigation
feat: the engine runs section 12's collection methods and index places, with sharp/mago at mago-sharp 3cc39cc8c - #114
Merged
Merged
Conversation
…rp-subclass fix: decide a call is php# by the class that declares the member
Problem: team-lead approved ParseError::ComputedParameterInSharp at the `=>`, with the design note's message. The first build reported it over the `=>` and its whole expression, and said "A parameter" where the note says "A constructor parameter". Solution: The error's span is the `=>` alone, and its message is the note's: "A constructor parameter cannot be a computed property: a computed property has no incoming value to receive." The expression is still parsed and skipped, so the class parses on. crates/syntax/ ├── src/error.rs <- the note's message ├── src/parser/internal/function_like/parameter.rs <- the span is the `=>` └── tests/sharp.rs <- the error's text and span
test: every .sharp issue speaks PHP#, and .php twins stay only on shared code
… runs Problem The "Install elan and Lean" step never installed Lean. elan-init.sh with --default-toolchain only sets the default toolchain, so the step took 333 ms and passed without a download. The first test that ran lake installed Lean 4.34.1 instead, and the 20 law tests in tests/compile.rs each started the same install in parallel. On #153's run 38170197612 that race failed the Ubuntu nightly job. The tests waited on elan's lock, found a half-installed toolchain ("lake: error while loading shared libraries: libInit_shared.so"), could not remove elan's temp toolchain directory, and one could not resolve release.lean-lang.org. CI showed 20 failing tests for one network problem, and a rerun passed. Solution The step installs the toolchain from crates/sharp-lean/lean/lean-toolchain with elan toolchain install, then runs that toolchain's lake --version and lean --version. If any part fails, it uninstalls the toolchain, since elan reports a half-installed one as installed, and tries again after 15 and then 30 seconds. After 3 failed attempts the step fails with one error that names the version, and no test runs. cd.yml's two uses of the action get the same check. .github/actions/setup-lean/ action.yml installs the pinned toolchain, checks its lake and lean run, and retries a failed install twice
Problem The Lean setup step must fail, and name why, when the pinned toolchain cannot install. No CI run has shown it fail yet. Solution The step installs leanprover/lean4:v0.0.0 for one CI run. The next commit restores the version from crates/sharp-lean/lean/lean-toolchain. .github/actions/setup-lean/ action.yml installs leanprover/lean4:v0.0.0
Problem The Lean setup step installs leanprover/lean4:v0.0.0, which proved the step fails and names the cause on run 38175864908, so every job that sets up Lean fails. Solution The step reads the version from crates/sharp-lean/lean/lean-toolchain again. .github/actions/setup-lean/ action.yml installs the version in lean-toolchain
Problem:
Spec section 9.1 writes `public Order(Row row) : super(row) { }`. The
parser read `: super` as a return type, so it gave four generic parse
errors. Without it, a subclass constructor compiled and never ran its
parent's: `class Child : Base { public Child(Row row) { } }` left `Base`'s
get-only `row` unset, and reading it threw PHP's "must not be accessed
before initialization". A class with a non-constant initial value and no
constructor got a generated `__construct()` that dropped `new`'s arguments
and never called its parent either.
Solution:
- The parser reads `: super(…)` or `: this(…)` after a PHP# constructor's
parameters into Method.initializer, a ConstructorInitializer. Any other
word after `:` is one ParseError::ConstructorInitializerInSharp: "A
constructor passes control with `: super(…)` or `: this(…)`."
- check_slice refuses `: this(…)` on the main constructor: "The main
constructor passes control to its base class with `: super(…)`. Only a
named constructor calls `: this(…)`." The arguments of `: super(…)` are a
method body's expressions, and `this` in them is "`this` is not available
before the constructor runs: pass a parameter instead.", after C#'s CS0027.
- The analyzer checks `: super(…)` as PHP's `parent::__construct(…)`, before
the body, so argument errors keep PHP's codes and the readonly check counts
the call. With no constructor above the class, `: super()` does nothing and
any argument is too-many-arguments: "`Base` has no constructor to call:
remove the arguments."
- Interim ruling on an implicit `super()`: a constructor without `: super(…)`
in a class whose base class has a constructor is the new missing-super-call:
"`Child`'s constructor must call `Base`'s with `: super(…)`."
- A class without a constructor, whose initial values run in the generated
one, under a base class whose constructor takes parameters, is
not-supported-yet.
- The bridge emits `parent::__construct(args)` after the Set conversions and
the initial values, before the body. The generated constructor calls
`parent::__construct()` when a constructor exists above the class.
- A parameter `: super(…)` passes on is used. The effects summary walks the
initializer, so `new` reaches its arguments' effects and the base class
constructor's. The method fingerprint hashes it.
crates/
├── syntax/src/
│ ├── cst/cst/class_like/constructor.rs <- added: ConstructorInitializer { colon, keyword, argument_list }
│ ├── cst/cst/class_like/method.rs <- Method.initializer; PHP never sets it
│ ├── cst/node.rs, walker/mod.rs <- Node::ConstructorInitializer, walked before the body
│ ├── error.rs <- ParseError::ConstructorInitializerInSharp
│ └── parser/internal/class_like/method.rs <- parse_optional_constructor_initializer
├── semantics/src/internal/checker/sharp.rs <- `: this(…)` refused; `this` in the arguments refused; doc
├── analyzer/src/
│ ├── code.rs <- IssueCode::MissingSuperCall
│ ├── statement/class_like/method.rs <- analyze_constructor_initializer; check_super_call
│ ├── statement/class_like/mod.rs <- runs check_super_call on a PHP# class
│ ├── statement/function_like/mod.rs <- analyze_function_like runs the initializer before the body
│ ├── expression/call/static_method_call.rs <- analyze_static_method_call visible to the crate
│ └── effects/summary.rs <- record walks the initializer
├── fingerprint/src/class_like/mod.rs <- hashes the initializer with the body
├── hir/src/lower/error/mod.rs <- the new parse error is an unexpected token
├── sharp-bridge/src/
│ ├── lower.rs <- parent::__construct(…) for `: super(…)` and the generated constructor
│ └── lower/types.rs <- Types::parent_constructor
├── syntax/tests/sharp.rs <- `: super`/`: this` parse; any other word is one error
├── semantics/tests/sharp.rs <- `: this` on the main constructor; `this` in the arguments
├── analyzer/tests/sharp.rs <- argument check; readonly tracking; no constructor above;
│ missing-super-call; the generated-constructor refusal;
│ a used parameter; effects through `: super`
├── fingerprint/tests/signature_changes.rs <- a `: super` argument change changes the fingerprint
└── sharp-bridge/tests/lower.rs <- parent::__construct placement; generated constructor; no-op `: super()`
composer/src/Sdk/Syntax/NodeKind.php <- regenerated
scripts/regen-analyzer-issue-codes.php <- missing-super-call
…itializer # Conflicts: # crates/analyzer/src/effects/summary.rs
…d mutants show what no test checks
Problem
Agents add tests to pin behaviour without asking whether a test adds
anything. The test audit measured it: 31 of 66 sampled tests in
crates/analyzer/tests/sharp.rs add no covered line or region. CI runs
every test but measures neither what a pull request's code is covered
by nor whether a test would fail if that code broke, so a pull request
can add untested code, or tests that check nothing, and pass.
Solution
patch-coverage, required through ci-passed, runs cargo llvm-cov over
mago-analyzer's sharp tests, mago-semantics' sharp tests and every
mago-sharp-bridge test, and diff-cover fails when a line the pull
request adds in crates/analyzer/src, crates/semantics/src or
crates/sharp-bridge/src is not covered. Each missing line is an error
annotation on the pull request. It runs on nightly, because only
nightly honours #[coverage(off)], cargo-llvm-cov's way to exclude a
function that cannot run by design:
#[cfg_attr(coverage_nightly, coverage(off))]. The three crate roots
enable the attribute under cargo-llvm-cov on nightly, and the
workspace declares the coverage_nightly cfg so other builds stay
warning-free.
mutants-plan lists the pull request's mutants in the same three
folders with cargo mutants --in-diff, and mutants tests them in shards
of 10 on at most 8 runners, against the same three test targets. Each
surviving mutant is a warning annotation on its line. mutants never
feeds ci-passed. ci-passed allows patch-coverage to be skipped only
off a pull request.
.github/workflows/
ci.yml patch-coverage, mutants-plan and mutants;
ci-passed needs patch-coverage
Cargo.toml unexpected_cfgs knows cfg(coverage_nightly)
crates/
analyzer/src/lib.rs enables coverage_attribute under coverage_nightly
semantics/src/lib.rs enables coverage_attribute under coverage_nightly
sharp-bridge/src/lib.rs enables coverage_attribute under coverage_nightly
Problem patch-coverage must fail a pull request that adds a line no test runs, name its file and line, and leave alone a function marked #[cfg_attr(coverage_nightly, coverage(off))]. Solution written returns nameless() when both the class and the member are empty, which no test reaches. nameless is excluded from coverage. The next commit reverts this one. crates/analyzer/src/effects/ mod.rs written calls nameless for a call with no class and no member
feat: PHP# module laws in Module.sharp, proven in Module.lean
Problem The previous commit added nameless and the uncovered line that calls it, only to prove that patch-coverage fails on that line. Solution written is again as on master. crates/analyzer/src/effects/ mod.rs written no longer calls nameless, and nameless is gone
Problem mutants must report a line every test runs but no test checks, while patch-coverage and ci-passed still pass. Solution written reserves spare(member) more bytes in the text it returns. The tests run that line, but no output depends on a string's capacity, so the mutants of spare survive. The next commit reverts this one. crates/analyzer/src/effects/ mod.rs written reserves spare(member) bytes after a class and member
Problem The previous commit added spare and the reserve that calls it, only to prove that mutants reports a mutant no test catches. Solution written is again as on master. crates/analyzer/src/effects/ mod.rs written no longer reserves spare(member) bytes, and spare is gone
Problem: - `(lazy) => lazy ? 1 : 0` and `(lazy, int fallback) => …` compiled on master and gave a parse error here: `lazy` before `)` or `,` was read as a modifier. - The computed-parameter error said "A constructor parameter" on every PHP# parameter, method and lambda parameters included. - `public int Report() => 1;` followed by the constructor `Report` was called a second constructor, beside the method's own error. - `lazy int extra` on a method parameter also got PHP's "Promoted properties are not allowed outside of constructors.", because any modifier counted as promotion. - Deleting the `is_sharp()` check, or widening the guard clause to `break`, `continue` or a loop body, failed no test. Solution: - parse_optional_modifier reads a word as a modifier only when the next token is not `(`, `)`, `,` or `=`, the rule parse_parameter uses. - The computed-parameter error reads "A parameter cannot be a computed property: a computed property has no incoming value to receive." - check_members records the main constructor's span and reports only a constructor after a constructor. A constructor after a method of its name is not reported again; the method keeps its own error. - is_promoted_property does not count `lazy`, which declares no member. - New test rows pin each case. crates/ ├── syntax/src/ │ ├── parser/internal/modifier.rs <- a word before `(`, `)`, `,` or `=` is a name │ ├── error.rs <- "A parameter cannot be a computed property" │ └── cst/cst/function_like/parameter.rs <- is_promoted_property skips `lazy` ├── semantics/src/internal/checker/class_like/mod.rs <- the main constructor's span decides a second one ├── syntax/tests/sharp.rs <- lambda parameters named `lazy`; a computed method parameter ├── semantics/tests/sharp.rs <- loop and `break`/`continue` rows; a method then a constructor; │ `lazy` on a method parameter is one error └── semantics/tests/duplicate_members.rs <- a PHP method defined twice keeps PHP's message
…tors # Conflicts: # crates/hir/src/lower/error/mod.rs # crates/syntax/src/error.rs
ci: fail the Lean setup step unless the pinned toolchain installs and runs
…ackages Problem patch-coverage measured only the PHP# suites: analyzer's and semantics' tests/sharp.rs and the bridge's tests. crates/analyzer/src and crates/semantics/src also hold the plain PHP code those suites never run, which the packages' other tests cover. A correct pull request that changes such a line, as #154 changed get_parameter_type, failed patch-coverage, and its mutants survived in mutants because no PHP test ran against them. Solution patch-coverage runs every test target of mago-analyzer, mago-semantics and mago-sharp-bridge in one cargo llvm-cov run. mutants runs every test target of the three packages against each mutant (--tests, the targets cargo llvm-cov runs), instead of only sharp, lower and unit. .github/workflows/ ci.yml patch-coverage and mutants run every test of the three packages
Problem patch-coverage must pass a correct change to shared code that only a plain PHP test runs. Line 53 of the PSL shape provider runs under analyzer's PHP tests and under no PHP# test. Solution ShapeProvider::get_return_type names its argument as a byte slice, a change with the same behaviour. The next commit reverts this one. crates/analyzer/src/plugin/libraries/psl/type_/ shape.rs get_return_type passes b"elements" as a slice
Problem
Spec section 28 makes a broken structure rule stop the code that breaks it,
as a type error does. mago compile never read a Module.lean: a file that
imports what its namespace's rule forbids compiled and ran, and a
Module.lean holding "this is not Lean at all" compiled too.
Solution
mago compile collects each .sharp file's facts (its declarations, imports
and name references) from the same checked program the Lean translation
reads. Every @[rule] of a Module.lean constrains the namespace of its
folder: the sharp-lean runner's new Rules request imports every
Module.lean Lake built and runs each rule over the facts under its
namespace. Each fact that breaks a rule refuses its file with broken-rule
on the code that holds the fact:
app/Shared/Ledger.sharp:3:8:error - broken-rule: This import of
App.Tenant.Store.Receipts breaks the structure rule neverReachesTenant
in app/Shared/Module.lean.
A Module.lean that Lean rejects refuses every file of its namespace with
the Module.lean and Lean's first error, or with the rejected Module.lean
it imports. @[rule] outside a Module.lean is a Lean error at the
attribute. Each .sharpc lists the Module.lean of its folder and of each
folder above it, so a changed rule makes the files it may judge stale, and
every rule runs over every file whenever one file is stale. Every
generated module imports Sharp.Lean.Facts, and a folder with only a
Module.lean gets an empty Code.<Namespace>.Module, so every Lean file
beside PHP# code starts with its own import and open Sharp. Lean::prove is
Lean::check, and a theorem in a proof file ends at the next line at the
margin, so an error in a rule after a proof is no longer blamed on that
law.
crates/sharp-lean/
├── lean/Sharp/Lean/Facts.lean <- added, from spike/lean-structure: facts, Graph, Rule,
│ Rule.each/eachIn/neverImports/importsOnly/noImportCycles, @[rule]
├── lean/Sharp/Lean/Runner.lean <- the Rules request (kind 3) and its Broken answer (kind 4)
├── lean/lakefile.toml <- Sharp.Lean.Facts joins the library's roots
└── src/
├── facts.rs <- added, from the spike's walker.rs: one file's facts
├── rules.rs <- added: finds each Module.lean, builds it, runs the rules, reports
├── lean.rs <- Lean::prove renamed Lean::check; proves laws, then checks rules
├── runner.rs <- runner::rules beside runner::check, one shared run and header
├── issues.rs <- broken_rule, rejected_rules, rejected_rules_import
├── package.rs <- one generated-module header with Facts; empty rules modules
├── library.rs <- embeds Facts.lean
├── translate/mod.rs <- Translation gains its file's facts
└── lib.rs <- exports rules_files, the Module.lean files that may judge a file
crates/analyzer/src/code.rs <- IssueCode::BrokenRule ("broken-rule"), regenerated
scripts/regen-analyzer-issue-codes.php <- lists broken-rule
crates/orchestrator/.../compile.rs <- compile(stamp, check); a file's Module.lean files are inputs
crates/server/src/server.rs <- Server::compile(stamp, check)
src/commands/compile.rs <- calls lean.check
tests/compile.rs <- the spike's integration tests, rewritten for .sharp and Module.lean
Completes: none (section 28 completes with PR 5)
Problem: section 12 names List contains, indexOf, insert, remove, clear and last, and Map has, keys and remove, and none exists in the checker or the engine. A Map's filter compiles and runs as the renumbering List filter, groupBy refuses a backed enum key, and the interim Map names delete and filterValues still compile. Section 12 holds 9 of the examples Guard 1 lists as failing, the most of any section. Solution: a design note for team-lead's approval before anyone builds. Each method's state today with its mago compile output at mago-sharp master 8818f95, the PHP it lowers to, the edge cases the spec leaves open with a proposal and its precedent, the public names, three mago-sharp PRs and one php-sharp PR, and the tests. Reads run inline as PHP on the array, as count does, and changes write back to their place, as a Set's do. docs/architecture/slices/ └── 12-collection-methods.md <- added: the Slice's design note
Problem: The bridge's is_default and the analyzer's runs_in_constructor each wrote the rule for which initial values run at the start of the constructor, and the bridge alone held is_readonly, the rule it depends on. The analyzer's refusal of a generated constructor under a base constructor with parameters must match what the bridge emits, and two copies can drift. Solution: - PropertyHookList::is_readonly, moved from the bridge: a get-only auto-property, which runs as `readonly`. - Property::initial_value_runs_in_constructor: a value that is not constant, or any value of a `readonly` property. It calls is_readonly. - The bridge's is_readonly and is_default and the analyzer's runs_in_constructor are deleted. accessor_flags, Lowering::class, Lowering::property and check_super_call call the two methods. crates/ ├── syntax/src/cst/cst/class_like/property.rs <- PropertyHookList::is_readonly; Property::initial_value_runs_in_constructor ├── sharp-bridge/src/lower.rs <- is_readonly and is_default deleted; callers use the methods └── analyzer/src/statement/class_like/method.rs <- runs_in_constructor deleted; check_super_call uses the method
This was referenced Oct 13, 2026
fix: a file that imports a class named like an effect still writes the effect in uses
…ds at its limit
Problem
A SIGINT, SIGQUIT, SIGHUP or SIGTERM that reached Mago between `command.spawn()` and the store of Lake's group found no
group to forward to. Mago ended, and Lake and its Lean ran on with no parent: a waiting Lean never stopped. Blocking the
signals on the spawning thread does not close it, since any of Mago's other threads can take the signal.
The runner's deadline counted wall time, so a rule that computed on a fraction of a core was refused as "waited",
though it never waited.
The limit row's slow rules took 3.3 processor seconds each on macOS and up to 8.7 on Linux aarch64, too close to the
10-second limit, and the signal test sent only SIGINT, so dropping any other forwarded signal failed no test.
Solution
While the spawn runs, `WAITED_ON` holds `STARTING`. `forward` records the signal in `PENDING` and returns, and the
spawning thread sends it on once it knows the group. `forward` writes `PENDING` before it reads `WAITED_ON`, and the
spawning thread writes `WAITED_ON` before it reads `PENDING`, so one of them always forwards.
The runner's watchdog counts the deadline only while the rule's processor time stands still. A sleeping rule is still
refused as waited, and a computing rule ends only at its processor limit.
The limit row's slow rules are a third the size, thirty to a row, so each has room under the limit and each runner
still passes its own limit and restarts. The signal test has a row for each forwarded signal.
crates/sharp-lean/
├── lean/Sharp/Lean/Runner.lean watched counts the deadline only while processorTime stands still
└── src/library.rs STARTING and PENDING: a signal during the spawn waits for the group
tests/compile.rs looping(steps); thirty slow rules per row; a_signal_that_ends_a_compile_ends_the_lean_it_waits_on
with SIGINT, SIGQUIT, SIGHUP and SIGTERM rows
Problem On Linux CI, a SIGQUIT to the compile's group ended Mago, and Mago forwarded SIGQUIT to Lake's group, but the sleeping Lean was still alive 10 seconds later. SIGQUIT's default action dumps a core, and a kernel that pipes cores to a helper ignores RLIMIT_CORE, so a Lean can stay alive while its core is written. Solution `forward` ends Lake's group with SIGKILL for every signal it catches, as `end_group` does at the deadline, then raises the signal it caught, so Mago itself still ends by that signal. crates/sharp-lean/src/library.rs forward ends the group with SIGKILL tests/compile.rs the signal test says Mago ends Lake's group
heyJordanParker
added a commit
that referenced
this pull request
Oct 13, 2026
Problem: team-lead's Queue 23 builds Map and Set as engine objects on #114 as it stands, and #114 rewrites the collection receiver and sharp_collection_key_slot, which this branch also changes. Solution: the merge keeps both sides. sharp.c conflicted twice. The first conflict keeps this branch's key text, which the Map and Set objects delete next, and #114's sharp_collection_renumber, and drops the copy of sharp_collection_key's header this side ended with, since #114 moved that function up. The second keeps #114's comment on sharp_collection_key_slot, which now names both the backed enum arm and the struct arm. StaticCollections' Log.note named its parameter event, which the Mago this branch builds refuses as a PHP# keyword, so it is entry. Checked with slot 9's Mago, which contains #114's pinned a9f1882: 175 of Zend/tests/sharp's 176 tests pass without opcache. opcodes.phpt fails because that Mago gives every PHP# class parse and tryParse (Queue 18), which no PHP twin has, so the test learns to leave them out when this branch moves the pin. ext/sharp/ └── sharp.c both conflicts resolved Zend/tests/sharp/ └── StaticCollections.sharp Log.note(string entry)
Problem Linux CI refused the limit row's endless proof as "it waited 120 seconds" instead of "ran past 30 processor seconds", twice in a row. Its `repeat (first | skip)` piles up goals: in a Linux aarch64 container its Lean held 1.0 GB after 1 processor second and 4.9 GB after 30, so a faster core fills the runner's memory before the limit, and the Lean then waits on the disk instead of computing. Solution The proof's tactic is a `run_tac` loop, which Lean's own heartbeat limit does not stop either. In the container its Lean held 858 MB from its first second to its limit, and it is refused as "ran past 30 processor seconds". With the carry in `Package::errors` off, its compile used 74.7 processor seconds, past the row's bound of 60. tests/compile.rs the endless proof is a run_tac loop
fix: Lean work stops at a processor-time limit, concurrent first calls to lake take turns, and laws reach interfaces
# Conflicts: # ext/sharp/sharp_unit.h # sharp/baseline/spec~HEAD
# Conflicts: # sharp/mago/.github/actions/setup-lean/action.yml # sharp/mago/.github/workflows/ci.yml
# Conflicts: # sharp/mago/.github/workflows/ci.yml
…arp 164ef44 #114's tests of a change after ?. on a List index need mago-sharp #176, which types that index nullable and marks it ZEND_DIM_IS. a9f1882, the pin, predates it, so mago compile refused Grid.sharp. The pull goes on to 164ef44, the merge of #176. That Mago makes event a keyword (#170), so Log.note's parameter becomes entry. The 20 examples that Mago passes leave sharp/baseline/spec, and no example joins it. Co-Authored-By: Claude <[email protected]>
mago-sharp measured each pull request's new lines from #158 on. #150, module laws, and #154, a call decided by the class that declares the member, merged before it, so seven of their lines never ran under a test. php-sharp measures the whole subtree pull, so patch-coverage failed on them. - A plain PHP call that spreads a list of known count through a PHP# subclass is checked against the parent's docblock type. - A module outside Module.sharp adds no analyzer issue, and a plain PHP class that holds the module's name makes the module a duplicate. - A module's metadata is looked up as an event's is: the scanner always registers the name, so the lookup has no warning branch. - The note for a refusal inside a module is unreachable!: a module holds only laws, and semantics takes each one. Co-Authored-By: Claude <[email protected]>
# Conflicts: # sharp/mago/crates/analyzer/tests/sharp.rs
At 164ef44, LINUX failed class-law and module-law: both compiled a law at once, and the image's elan installed Lean twice into one folder. mago-sharp #175 makes concurrent first calls to lake take turns, so the pull goes on to 3cc39cc, its merge. #175 also lets a law reach an interface, so state-machine-law passes and leaves sharp/baseline/spec. Co-Authored-By: Claude <[email protected]>
This was referenced Oct 13, 2026
heyJordanParker
added a commit
that referenced
this pull request
Oct 13, 2026
Master brings #114: the engine runs section 12's collection methods and index places, and `sharp/mago/` moves to mago-sharp 3cc39cc. It updates the five engine fixtures that the slice's Mago refused, so `mago compile` compiles all 111 again. 3cc39cc also brings mago-sharp #175 and #177, which git merged into the slice's Mago without a conflict. Six files conflicted, and each keeps both sides: - `ext/sharp/sharp_arginfo.h` is regenerated from the merged `sharp.stub.php`, which holds master's `insert`, `removeAt`, `put` and `clear` and the slice's `\Sharp\Internal` functions. - `index_read.inc` keeps master's two `count` calls and the slice's three `standing` calls. - `enum_keys.phpt` and its two JIT twins keep the slice's `TypeError`: the Map's check refuses the key "missing" where plain PHP hands the Map in, before master's loop would convert it. Master's new `nest` line moves `byName` to line 67. `enum_keys.inc`'s comment that plain PHP collections are not checked is no longer true, and now says where the key fails. - `opcodes.phpt` keeps master's 16 op arrays for `EnumKeys` and the slice's check lines, with one for each of master's `grouped` and `groupNames`. Zend/tests/sharp/ ├── enum_keys.inc <- the comment says where the key fails ├── enum_keys.phpt, enum_keys_jit_function.phpt, enum_keys_jit_tracing.phpt │ <- the slice's TypeError, at line 67 ├── index_read.inc <- both sides' calls └── opcodes.phpt <- master's count, the slice's checks ext/sharp/sharp_arginfo.h <- regenerated from the merged stub
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
mago-sharp #163 and #166 lower spec section 12's collection methods and index places to Sharp\Collection methods the engine did not have. The engine pinned mago-sharp 625c278, which lowers none of them. So with the new Mago, PHP# code broke at runtime in four ways:
insertandremovethrew "Call to undefined method".grid[0].add(5)andmaps[0]["c"] = 3threw "Call to a member function on array".points[5].x = 5on a missing index wrote a null into the list, then threw "Attempt to assign property on null", where section 12 throws OutOfRangeException.The engine tests also wrote their temp folders under fixed names, so two runs at once compiled into each other's folders.
Solution
The engine runs every section 12 change.
Sharp\Collectiongainsinsert,removeAt,putandclear. Each one writes back through a property's set hook once.zend_compile_sharp_receiverreads an index receiver through its container. Sogrid[0].add(5)changes the element the list stores. The receiver then falls through to the(object)cast, so an element a plain PHPArrayAccessobject gives is a collection again, as on master.zend_delayed_compile_propreads a PHP# index whose property is written. A missing index then throws OutOfRangeException and leaves no gap.sharp_collection_key_slotstores a backed enum case under its backing value.After
?., a change through aListindex reaches the stored element, and a null element or a missing index skips the call. Spec line 840 says "AMapread is handled where it is read, with??,?.,is,as,matchorget", and line 854 says "The same holds for aListindex". mago-sharp fix: every form PHP# never writes fails as a typo does #176 marks theListindex directly before?.withZEND_DIM_ISon every path, sorows[0]?.add(5)lowers to$rows[0]?->add(5). For that mark,zend_compile_sharp_receiverandzend_delayed_compile_dimemitFETCH_DIM_ISand keep the container a bare read.sharp_collection_read_dimensiongives null for a missing index underBP_VAR_IS. The call'sJMP_NULLthen skips it. Only that index reads quietly, socube[9][0]?.clear()throws oncube[9]. A barerows[9].add(7)still throws OutOfRangeException. The branch needsZEND_DIM_SHARP, which only the bridge sets, so plain PHP's opcodes do not change.Every engine test writes its temp folders under its own process ID. This covers project.inc, library_autoload.inc, native_generator, native_generator_refusal, compile_command and refusal_unrooted.
sharp/magomoves to mago-sharp 3cc39cc, the merge of feat: a write through ?. happens only when every ?. receiver is not null #175. The branch merges master, where Mago lives insharp/mago/, and pulls mago-sharp bygit subtree pull, asdocs/architecture/mago.mdsays. Its pin was a9f1882, the merge of fix: a PHP form PHP# never has is refused for good, with what PHP# writes instead #166, which predates two fixes this PR needs:Listindex before?.nullable and marks itZEND_DIM_IS. Without it,mago compilerefusedGrid.sharp's?.rows.laketake turns. Without it,LINUXfailedclass-lawandmodule-law: both compiled a law at once, and the image's elan installed Lean twice into one folder.The pull also brings fix: a lambda the preload script runs keeps working under the JIT #170, feat: a constant's value is any expression built from constants #173 and feat: Self members, named constructors through a type parameter, generic events and intersections #177. fix: a lambda the preload script runs keeps working under the JIT #170 makes
eventa keyword, soLog.note's parameter inStaticCollections.sharpbecomesentry.ext/sharp/sharp_unit.his the header the bridge'sbuild.rswrites, and names no Mago commit.Every line the pull adds runs under a test. mago-sharp fix: sharp/bin/spec gives each setup type of a named block a file of its own #150 and fix: the spec check reads an => line under a signature and a bodyless declaration #154 merged before mago-sharp measured each pull request's new lines, so seven of their lines never ran.
patch-coveragemeasures the whole pull, so this PR covers them:Module.sharpadds no analyzer issue, and a plain PHP class holding the module's name makes the module a duplicate;unreachable!, since a module holds only laws and semantics takes each one.The spec self-test's refusal example becomes
public static int total { get => 1; }. This Mago compiles the old example, a bracelessif (true) return;, so it no longer showed a "not supported yet" refusal.Spec examples
sharp/bin/test --specpasses these 21 examples. They leavesharp/baseline/spec/, and no entry joins it:Every §9.1 and §28 example passes. Section 12 still fails these examples:
getOrNulland a write by indexCompletes: §9.1
Verification
sharp/bin/test --census --differential --specat 3cc39cc on macOS:sharp/baseline/spec/: 179 examples checked, 1 ignored, 92 fail.cargo test -p mago-analyzer -p mago-semantics -p mago-sharp-bridgepasses, and so docargo fmt --checkandcargo clippy -D warningson the two changed crates.sharp/bin/spec --base origin/masterreports "0 entries join sharp/baseline/spec, 21 leave it."sharp/bin/spec --completeson this body reports "§9.1: all 4 checked examples pass."mago analyzeofsharp/composerfinds no issues. The bridge's generatedsharp_unit.handkind.rsequal the committed ones.The engine suite runs
index_changesagainst #176's lowering. It covers these cases:?.on a local, a property and a hooked property:rows[0]?.add(5)changes the stored element, androws[1]?.add(6)on a null element skips.rows[9]?.add(7),clear,remove,containsandcounton a missing index skip, and the hook count shows no write.?.on a missing index (points[5]?.x) gives null on a local, a property and a hooked property.?.skips the call for each of these:insert,indexOf,lastandentriesList<Point>elementList<Map>element'sremoveandhasList<Set>element'sadd,remove,clearandcontainscube[9][0]?.withadd,clear,remove,count,containsandentriesthrows oncube[9].rows[9].add(7)on a property and a hooked property throws OutOfRangeException.mapon an element of a plain PHPArrayAccessholder works.clearon an element of a hooked property writes back once.Each piece fails its rows when it is taken out:
FETCH_DIM_ISinzend_compile_sharp_receiver, or without the quiet read, the threerows[9]?.add(7)rows throw.FETCH_DIM_ISinzend_delayed_compile_dim, the threerows[9]?.clear()rows, theList<Set>row and the property read throw.clear,remove,countandcontainsskip.clearwrite-back, the clear is lost and the hook count stays 0.Files