Skip to content

Major Bug fixes for next minor release (v0.15.0) - #145

Merged
rcalicdan merged 24 commits into
mainfrom
internal-improvements-56
Dec 5, 2026
Merged

rcalicdan merged 24 commits into
mainfrom
internal-improvements-56

Conversation

@rcalicdan

@rcalicdan rcalicdan commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Woop-woop, Hardening the runtime checker and resolving edge cases.. Yeah..

1. Type Checking & Variance Soundness

  • Bare array Contract Enforcement: Stopped treating bare array as an unconstrained mixed bypass in parameters and return types unless guaranteed by a native non-nullable array typehint.
  • Generic Contravariance Inversion Fix: Corrected inverted supertype checks for @template-contravariant across scalars, ranges, literals, class-string<T>, object, collections, unions, and intersections.
  • Preserved Pragmatic Union Subtyping: Retained intentional runtime subset compatibility for unions and upper bounds on invariant containers (protecting real-world frameworks like Noctud and Tempest while relying on \WeakMap to halt invalid mutations).

2. AST Transformation & Single-Evaluation Guarantees

  • Impure clone & PHP 8.5 clone($obj, [...]):
    • Replaced double-evaluation AST expansions with single-evaluation cloner closures (executeClone() / executeCloneWith()).
    • Switched pending clone tracking to an exception-safe stack (pushPendingCloneSource() / popPendingCloneSource()) with try/finally unwinding to support nested clones inside __clone().
  • By-Reference Return Guards: Ensured by-reference return expressions (return $this->slot();) evaluate exactly once and preserve reference aliasing.
  • Evaluation Order for @param-out & @self-out: Hoisted return expressions before exit checks so post-conditions evaluate after the return expression executes (and are skipped if the return expression throws).
  • Semantics for ++ / -- and ??=:
    • Replaced arithmetic rewrites with computeInc() / computeDec() to preserve PHP's native semantics on strings, null, and booleans.
    • Rewrote ??= to $target ?? ($target = check(...)) to preserve short-circuiting, uninitialized readonly properties, and PHP 8.4 set hooks.
  • Zero Line-Drift on Multi-line Constructors: Preserved argument newline spans on withPendingGeneric() for multi-line constructor calls (e.g. new Pair(\n 1,\n 2\n)).

3. Compile-Time Static Elimination Soundness

  • \FullyQualified & namespace\ Class Resolution: Switched ObjectEvaluator and ConstantAndEnumEvaluator to strict syntactic AST name resolution without stripping leading slashes.
  • Numeric String & Negative Array Keys: Mirrored PHP's runtime coercion of canonical numeric string keys to int and implemented PHP 8+ lazy auto-incrementing key rules (nextFreeElement) in ArrayLiteralEvaluator.
  • int-mask-of Constant Verification: Verified via non-autoloading reflection that constants matching int-mask-of<Class::*> are genuine integers (not strings, floats, booleans, or enum case objects).
  • Implicit Nullability & Mutating yield Keys: Prevented eliminating setupScope() on int $x = null when respect_native_nullability = false, and prevented eliminating checkYield() when the yield key expression mutates the yielded variable.

4. Diagnostics, Cache & Test Parity

  • User src/Internal/ Paths: Switched ErrorFactory and ViolationCollector to PathMatcher::isLibraryInternal() so user applications containing a src/Internal/ folder do not have their stack frames and violation attributions stripped.
  • Opcode Parity & Cache Bump: Added PropertyOpcodeParityTest verifying mirrored opcode alignment, and bumped CacheManager::VERSION_PREFIX to v0.14.5_.
  • Documentation: Updated generics documentation covering variance nuances, clone stack guarantees, post-condition evaluation order, and constructor optional defaults vs. property writes.

…rnChecker, and DocblockParser; add tests for bare array enforcement and fix bug for bare array type-checking
…or internal directory checks; add UserInternalDirectoryTraceTest for enhanced violation reporting
…olution; add FullyQualifiedNameEliminationTest for comprehensive coverage of FQCN handling
…; refactor related methods and tests for PHP 8.5 clone syntax support
…ests for numeric string key coercion and auto-index behavior
…tants; add IntMaskOfConstantSoundnessTest for comprehensive validation of int-mask behavior
…eInc and computeDec methods in RuntimeTypeChecker; enhance FunctionContractInjector with nullability checks; introduce tests for increment/decrement and coalesce assignment semantics.
…tween MemberAssignChecker and RuntimeTypeChecker
… tests for line number preservation in generic constructor calls
@rcalicdan rcalicdan changed the title Next Minor Release (v0.15.0) Major Bug fixes for next minor release (v0.15.0) Dec 4, 2026
… InlineChecker and SpecialTypeResolver; introduce tests for inline routing and scalar refinements
…ics; update StaticTypeEvaluator and FunctionContractInjector to utilize new checks; add EliminationBox and ObjectGenericReturnEliminationTest for comprehensive testing of elimination safety rules.
…per for traversable type checks; add new IterableWrapper methods for enhanced type validation; introduce Nullable and Union Iterable Return tests for comprehensive coverage.
…prehensive tests for discriminated unions, including boolean, null, multi-field, and enum discriminators.
…add DynamicNumericStringKeyEliminationTest for comprehensive coverage of dynamic numeric string keys in array evaluations.
…d update tests for generic binding preservation and error handling
…variance handling; add InvariantNullableUnionVarianceTest for comprehensive coverage of variance behavior in generics.
… handling; introduce UnionIterableMapFixture for improved type checking in union scenarios.
…ethods for invariant intersection equality and flattening intersection members. Enhance InvariantNullableUnionVarianceTest with new tests for covariant and contravariant variance boxes.
…ce methods for splitting phrases and add comprehensive tests for various violation scenarios.
@rcalicdan
rcalicdan merged commit 8b7f6b3 into main Dec 5, 2026
21 checks passed
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