Repository navigation
Front end: every error in one pass, --check, undeclared names ranked by reachability - #634
Merged
Merged
Conversation
…agnostics still surface
… boundary With a diagnostics sink, an exception escaping lowerFunction, a method (lowerMethodFn / lazy-body materialisation), a class or a top-level statement is recorded (lower.internal, or parse.error with the ParseError's own line for a lazy body) and lowering moves on; the failed unit is not added to the module. Synthesized helpers stay outside the boundary. release* still run after a failed class. recoverLowering resets the per-function state lowering sets and restores without a finally: currentLowerClass, currentLowerFn, currentLowerFnHasThis, currentTypeParams, currentTypeBounds, currentTypeSubst, currentStaticClass, currentTypeDefClass, currentRefParamNames, currentLowerParams, currentLowerParamHints, currentArrayCaps, constCallables, localNewClasses, lowerInMain, bindLateThis, lowerClosureDepth, closureMagic, silenceDepth, sawYield, sawFuncArgs, sawStaticUse, lvHoist, lvTemps, valueTemps, stmtAssign, pendingCallInits, pendingCallPost, scopedIncludeStack, declTableBusy. A failed method re-enters the class scope (type params, bounds, subst, namespace) via restoreClassScope.
…pans for typedef/reify errors, all parse errors of a lazy body, guarded tolerant re-parse
COMPILER_CLASSES: Closure (emitter statics, EmitLlvmObjects/staticClassAbsent), Generator (emitter class_exists handling in EmitLlvmBuiltins), Ffi\Ptr (ptrIntrinsicClass).
…n static-prop store to an undeclared class
… a class named Numeric in a namespace
…check to user code, correct warning docs
…ite; check lazy include units
…tribute class-level sites to @Class:<FQN>
…bles, attribute bodiless method hints to their class
…rest by reachability
…factories, $x::K probe, callable arrays, static:: hierarchy, guards in switch/try and assignments
…namic reachability level
…ition negates the guard
… for unsupported.builtin
…r reachability errors
…in a used class still errors
… undeclared-name runtime trap
…-level guards; describe --allow-undefined-traps as it now behaves
Resolutions keep both sides: main's file fallback, nested-declaration hoisting, dynamic $GLOBALS keys and lazyUnitDone; this branch's lowerFail recording and diagnostics sink (attrCollectMode stays removed).
…functions are hoisted
…used class's constant table no longer marks it used; MANTICORE_REACH_DUMP=2 names why a class is used
…f id sets, property offsets
Keeps this branch's diagnostics sink beside main's prelude-demand stats step (#645).
…ering order changed
…ontinuous-cycles flatness test
…l gc_disable/gc_enable
…clared-function scan
This was referenced Nov 12, 2026
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 large app build stopped at the first front-end error. The external Laravel 13 report (#614) needed 15 full builds, each ~3 min and 11–14 GB, to find a dozen unsupported constructs. Parse errors, unsupported constructs and declaration/attribute errors each aborted the build on their own.
What changes
#[TypeDef]error into one diagnostics sink. It prints them all and stops before type inference (exit 65):parse.error,lower.unsupported,decl.error,attr.error,typedef.error,lower.internal.compile --check/build --check: run the front end only. A clean program exits 0 and no binary is written.analyze --deepreports what it did before, plus MIR findings that a declaration error used to hide.bin/buildis bit-identical across two runs.Numbers (
build --check, macOS arm64)Tests
tests/clicases:--checkon a clean program;--checkrejected bydump-*andanalyze;analyze --deepfinding both a declaration error and a type error.tests/aot/reject/multi_decl_errors. The reject suite passes 74/74.Known limits (follow-ups)
new Xis currently not reported until run time.Closes #627
Part 2 — undeclared classes, functions, constants as front-end warnings (#489, step 2)
Problem. A reference to a class, function or constant that nothing declares compiled silently and failed only at run time. For example, symfony-app without
symfony/stringbuilt green, then died onUnicodeString.new Xon an unknown class was not checked anywhere.What changes
(N uses)counted over distinct sites:undefined.class:new, static access,instanceof,catch, param/return/property type hints,extends/implements/traituse;undefined.function: direct calls. A function counts as defined if it is a module function, a linked.sigextern or an emitter builtin (BUILTIN_NAMES, kept in sync withemitBuiltinbytools/check_builtin_names.sh);undefined.constant: bare global constants.define, literalclass_aliastargets, namespace fallback anduse function/use constall count as declared.lib/*.oare unchanged, and the runtime traps stay. Errors for reachable references come with step 3 (reachability tiers).__mir_*/__mc_*are never checked.Found by the new check
src/Manticore/Main.php,namespace Manticore: twocatch (Throwable $e)resolved toManticore\Throwableand never caught anything. Fixed to\Throwable.numericas a scalar type, so a class namedNumericin a namespace (LaravelRule.php) stayed unqualified. Fixed;tests/parser/strict_invariance.shreports OK on 3187 files.exit;lowers toUndefined constant "exit". Repro added; filed as A bareexit;(no parentheses) throws "Undefined constant exit" instead of terminating. #635.Corpus (
build --check, rc=0 everywhere; warnings class/const/fn)Every class and constant warning was audited by hand against the app sources, vendor, prelude, stdlib and
.sig. One false positive (Numeric) was fixed at its root; the rest name genuinely absent symbols. The compiler's ownbuild --checkreports zero warnings.CI fix. The cli golden failed on macOS because
CI=1turns progress output on.diag()now runs commands withCIunset.Also addresses #489 (steps 1–2 of 4; reachability tiers and the shared declaration table follow).
Part 3 — reachability tiers: reachable undeclared names fail the build (#489, step 3)
What changes
Compile\Mir\Reachability) walks the MIR from the program roots:__main, include units, global initialisers, emitter-invoked factories, and every exported symbol for library targets.new, resolved static and late-static calls, literal-name method calls over instantiated classes, and callable literals in callable positions.$f(),new $x,$o->$m(),$cls::m(),unserialize, reflectionnewInstance*.$c = $x ? A::class : B::class; new $c.new, static access, call, constant,extends/implements) → error, exit 65, with(reachable: a <- b <- __main);instanceof,catch, type hints) or guarded reference → warning. Guards coverclass_exists/function_exists/extension_loaded/… inifarms, polarity-aware early exits,&&,?:, single-return guard helpers such asisSupported(), and guard-valued locals;--alllists them.php) →unsupported.builtinwarning, never an error.allowUndefinedglob patterns, which acknowledge specific missing names;--allow-undefined-traps, which restores the old runtime traps entirely.// @allow-undefined-traps, honoured by both test runners.Also fixed
exit;/die;lowered as an undeclared constant — Fixes A bareexit;(no parentheses) throws "Undefined constant exit" instead of terminating. #635 (repro promoted totests/aot/cases).Lowering changes to watch in the full suite
define()names that are foldable concatenations are now folded.Composer\Autoload\ClassLoadercounts as compiler-owned.$x::Kprobing no longer records class references.return/exitis no longer lowered.exit/diecount as terminators.Numbers. Reachability costs about 0.9 s of a 30 s
build --checkon laravel-app and symfony-demo (≈3%). The compiler's ownbuild --checkreports zero diagnostics.bin/buildoutput is bit-identical across rebuilds.Merged
main(#631, #616). Conflicts were resolved keeping both sides.