Repository navigation
fix: a compile after a warm pass types every class the pass skipped - #126
Merged
Merged
Conversation
A compile after a body-only edit panicked in the bridge with "the analysis types every expression of a file the checker accepted", when the service analyzes with `diff`, as `mago analyze --watch` does. The body-only pass marks every unchanged class safe, and the populator stores those marks in the codebase the service keeps. The compile step analyzes each file again, one at a time, with the same settings, so the analyzer skipped every class still marked safe and typed none of its expressions. The first one the bridge asked for was `money.amount() + Rate.percent()` in an unchanged file. The marks steer only the pass that set them. `run_analyzer_selective` now clears them once its analysis ran, so a one-file analysis after a warm pass covers the whole file. That also gives `analyze_file` and `analyze_file_with_artifacts` an unchanged file's issues and types again, for PHP too. Co-Authored-By: Claude <[email protected]>
…e's issues When the before-analysis hooks return references that differ from the last pass, `run_analyzer_selective` analyzes every file again, the ones the pass meant to skip too. Their classes were still marked safe, so under `diff`, as `mago analyze --watch` analyzes, the analyzer skipped them and their cached issues were replaced with none. An unchanged `Broken` lost its `invalid-return-statement`. It is the same cause as the warm compile: safe marks that outlive what they describe. `run_analyzer_selective` now clears them before it analyzes every file again. The server proof worker's before-analysis hook adds a reference while `PROOF_REFERENCE` is declared, so a test can change the hooks' references between two requests. Co-Authored-By: Claude <[email protected]>
heyJordanParker
added a commit
that referenced
this pull request
Oct 14, 2026
…eside structs and Map and Set objects
Problem
master gained spec section 32's modules and container, section 26's
extensions, and the warm-compile fix. Both sides changed the same bridge,
scanner, checker and flag code, so 13 files conflicted, and four places
compiled apart but not together.
Solution
Each side's behaviour stays, through one mechanism where both had one:
- A parameter's `Map` or `Set` crosses through `collection_parameters`,
which now takes any parameters, so master's extension members cross a
`Map` as well as a `Set`. master's `set_parameters`, `set_parameter` and
`set_from` go: `collection_parameters`, `collection_hint` and `crossed`
do their job.
- `attributes` takes the one group the lowering adds last: a property's
`#[\Sharp\Crossing]` or master's parameter `#[\Sharp\Internal\Service]`,
each from its own builder over a shared `attribute_group`.
- The test hooks of a test module's file go on a class in `class`, since
`class_members` serves a struct too and the module names only classes.
- `STRUCT` and `REQUIRED` move to flag bits 51 and 52, after master's
extension flags.
- The bridge's `constructor_parameters` for `new` becomes `new_parameters`,
beside master's `constructor_parameters` for the container.
- master's extension call drops the key argument our side deleted with the
key text, and `Key` joins the default class names master moved to
`shadowable_default_classes`.
- Two of master's test-module tests assert their rule rather than "no
method" and "no return anywhere", which every class's generated `parse`
and `tryParse` broke.
- `Stamp.sharp` calls `value.trim()`, as section 26 now requires.
`struct-equality` passes, a struct's `==` calling the new `trim()`, and
leaves the spec baseline.
- `sharp_arginfo.h` is regenerated from the merged stub.
php-sharp
├── ext/sharp/sharp_arginfo.h <- regenerated from the merged sharp.stub.php
├── Zend/tests/sharp/Stamp.sharp <- value.trim()
├── sharp/baseline/spec/§19/struct-equality <- deleted: the example passes
├── docs/architecture/slices/10-structs.md <- names collection_parameters and crossed
└── sharp/mago/
├── scripts/regen-analyzer-issue-codes.php
│ <- both sides' issue codes
└── crates/
├── codex/src/metadata/flags.rs <- STRUCT 1 << 51, REQUIRED 1 << 52
├── codex/src/scanner/ <- register_struct and walk_struct beside modules'
│ bindings; the names binding enum by its module path
├── names/src/lib.rs, internal/walker.rs
│ <- Sharp\Key a default class name
├── semantics/src/internal/checker/sharp.rs
│ <- check_struct_declaration beside check_extension
├── syntax/src/parser/internal/class_like/method.rs
│ <- both doc lines
└── sharp-bridge/
├── src/lower.rs <- collection_parameters for every parameter list;
│ attributes, crossing_attribute, service_attribute,
│ attribute_group; test hooks in class
├── src/lower/inline.rs <- form refuses a Map or Set parameter
├── src/lower/types.rs <- new_parameters
└── tests/lower.rs <- both sides' tests; two test-module asserts narrowed
heyJordanParker
added a commit
that referenced
this pull request
Oct 14, 2026
…compile fix (#126) Problem Master moved `Sharp\Environment` out of C into the standard library as a `foreign` class, and added `foreign` classes, `uses` on methods without a body, and the rule that no static holds a `foreign` object. Generics changed the same parser, binder, checker, bridge and extension files. Joined, four things broke: - `Method` grew by both sides' arena fields, and clippy's large_enum_variant refused `ClassLikeMember`. - A method value of a plain PHP `@template` method, as `List.wrap`, kept its unfixed `T`. Generics hold an unfixed type parameter to itself, so `Shelf.make(List.wrap)` into a `Function<List<Any?>(Any?)>` was refused. - Two generics fixtures implement a pure interface method with `sprintf`, which has no `extern`, so the effects check refused them. - The opcodes test pinned its `Generics` difference against the old `link` body. Solution - Keep both sides in every conflict. `ext/sharp/sharp.c` keeps the type texts and takes master's native `Environment.commandLine`, and `sharp_arginfo.h` is regenerated from the merged stub. sharp/bin/native writes the same `sharp_native.h` and `native.php`. - A method's `on` clause moves into the arena, as `type_parameters` and `uses` already sit there, so `Method` fits clippy's limit again. - `fix_type_arguments` infers a plain PHP method value's `@template` types from the function type it goes into, as it does a PHP# method's. A plain PHP method's type arguments never reach the engine, so it records none and refuses none, and the value stays PHP's first-class callable. - The fixtures build their strings with template strings, in the `.sharp` and its `.inc` twin alike, and the opcodes test pins the three `.php` lines the old `link` body hid. - A new analyzer test holds the join of the two features: a value whose type parameter has a `foreign` bound, and a generic class's `foreign` type argument, are refused in a static, and a bound that is no `foreign` class is not. ext/sharp/ sharp.c type texts kept, Environment from master sharp_arginfo.h regenerated from the merged stub sharp/mago/crates/ syntax/src/cst/cst/class_like/method.rs `on` lives in the arena syntax/src/parser/internal/class_like/method.rs allocates it syntax/src/parser/internal/statement.rs internal or foreign, one return path names/src/binding.rs both imports, `on` read as it is analyzer/src/resolver/property.rs plain PHP method values infer analyzer/src/statement/class_like/listener.rs `on` read as it is analyzer/src/expression/call/method_call.rs both imports semantics/src/internal/checker/sharp.rs an enum's `ClassLike` has both fields sharp-bridge/src/lower.rs static_type_text kept, master's class_flags doc orchestrator/src/service/incremental_analysis/compile.rs both tests kept whole analyzer/tests/sharp.rs foreign behind a type parameter or argument syntax/tests/sharp.rs `on` read as it is Zend/tests/sharp/ Generics.sharp, Generics.inc, TypeArguments.sharp template strings opcodes.phpt three pinned `.php` lines
heyJordanParker
added a commit
that referenced
this pull request
Oct 14, 2026
Brings #110, #113, #115, #118, #121 and #126. Both sides keep their behaviour: - #115 wraps `trim` with the extension `string.trim()` through `[Replaces]`, which this branch retires for the checker's table. The table gains `trim -> Sharp.Text.Text.trim`, and the table's member form renders an extension member on the call's first argument, as #115's wrapper did: `name.trim()`, `name.trim(…)`, `name.trim`, and the class's import only where the file lacks the extension by default. `Sharp\Replaces` leaves the default class names. #115's tests move to the table row. - Every PHP# source master adds calls plain PHP through `global.`: the library's Environment and Text extension, Accessors.sharp, Constructors.sharp, the test fixtures, and the slice notes. - The import check keeps #115's reference to an imported class, so its extensions reach the file. - Issue codes hold both sides': bare-function-call and function-import beside the effect and module codes. - §29 pure-interface joins sharp/baseline/spec again: this branch's example writes through `Files`, which ships with the effect classes.
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 compile after a warm pass panics in the bridge when the service analyzes with
diff, which is howmago analyze --watchanalyzes. A body-only edit is enough, such asreturn 1;toreturn 2;or=> cents;to=> cents + 1;:On
masteronly a warm compile hits it:mago compileanalyzes cold withoutdiff, andmago analyze --watchnever compiles. The warm compile tests and the coming daemon do hit it. The same stale state also hides an unchanged file's issues and types fromanalyze_fileandanalyze_file_with_artifacts, the one-file analysis an editor runs, for PHP too.Root cause
A body-only pass marks every unchanged class safe (
CodebaseMetadata::safe_symbols), andpopulate_codebase_innerstores the marks in the codebase the service keeps after the pass.compile'slower_allthen analyzes each.sharpfile again, one at a time, with the service's settings. Underdiffthe analyzer skips every class still marked safe, so it records no type for any expression in it. The span above ismoney.amount() + Rate.percent()in the unchangedapp/Order.sharp, the first expression the bridge asked a type for.Solution
The marks steer only the pass that set them.
run_analyzer_selectivewill clear them once its analysis ran:if !after_analysis { snapshots.clear(); } + // The safe marks tell this pass which code its skipped files' cached results stand for. An analysis of one file + // after it, as the compile step runs, analyzes and types the whole file. + codebase.safe_symbols.clear(); + codebase.safe_symbol_members.clear(); + Ok(SelectiveAnalysisOutput {The same stale marks broke a second path. When the before-analysis hooks return references that differ from the last pass,
run_analyzer_selectiveanalyzes every file again, the ones it meant to skip too. Their classes were still marked safe, so underdifftheir cached issues were replaced with none.run_analyzer_selectivewill clear the marks before that full re-analysis:let effective_skip_files = if references_changed { HashSet::default() } else { skip_files.clone() }; + // Changed references analyze every file again, the ones the pass meant to skip too, so no class stays safe. + if references_changed { + codebase.safe_symbols.clear(); + codebase.safe_symbol_members.clear(); + }The next warm pass sets its own marks before it reads any. The body-only path builds them from the class list, and the other path clears them first. A full analysis already leaves none, because
populate_codebasewrites empty sets.Changed PHP result
analyze_fileon an unchanged PHP file after a warmdiffpass now reports that file's issues. Before, the analyzer skipped its classes. WithChild extends BasereturningfloatoverBase::run(): stringand a privateunused()method, after a body edit to an unrelated file:Those are the issues a full analysis reports.
mago analyze --watchoutput does not change, because the pass's own issues come from the analysis that ran before the marks are cleared.Verification
a_compile_after_each_edit_matches_a_clean_compileonmasterpanics with the message above. With the fix it passes, and everyedits()row's warm compile equals the clean compile byte for byte after the header, with and withoutdiff.test_watch_one_file_analysis_after_a_body_change_in_an_unrelated_filefails without the fix (Only after the full analysis: [unused-method…, incompatible-return-type…]) and passes with it.a_warm_pass_whose_before_analysis_references_changed_reports_what_a_fresh_pass_reportsfails without the second fix (left: {},right: {"invalid-return-statement": ["Invalid return type for functionBroken::value: …"]}) and passes with it.--test server_engine: 12 passed.--test scoped_check, which shares the worker: 5 passed. Both ran withMAGO_REQUIRE_PHP_SDK_TESTS=1.cargo test -p mago-orchestrator --lib: 146 passed.cargo test -p mago-server: 2 passed.cargo clippy -p mago-orchestrator --tests -- -D warnings: clean.magofrom this head:mago compileon a two-file probe writes the same.sharpcbytes asmaster's, except the header'scheckerbuild ID and thekeythat hashes it.mago analyze --watchacross two body edits prints the same lines asmaster.