Repository navigation
Throw instead of coercing, fix 13 crash/IR bugs (coercion errors, null receivers, generators, closures) - #188
Merged
Merged
Conversation
…t the entering one Fixes #90
…lking it as a bag Fixes #179
… invalid Null/array/non-numeric string into an int parameter or return, null literal to a scalar parameter, array or non-numeric string operand of a mixed arithmetic op, object or array as an array key, negative str_repeat count, ArrayIterator and ArrayObject constructed from a scalar, foreach by reference over an iterator or generator. Inlined closures now apply the declared scalar return type, and the analyzer no longer reports scalar/scalar mismatches in files without strict_types. Fixes #82, Fixes #83, Fixes #37, Fixes #163, Fixes #140, Fixes #172, Fixes #84, Fixes #142, Fixes #147
Direct, method, static, constructor, dynamic-function and callback calls now raise ArgumentCountError instead of padding the missing slot. Dynamically named method calls still pad; kept as a repro under #175.
… method calls on a null receiver Dynamic method trampolines and spread fills now check the pack against the required parameter count. A method call (or fused Ds callback call) on a typed object local that holds null raises 'Call to a member function m() on null' instead of running or dereferencing null. Fixes #175, Fixes #148
…oop back-edge is a callable Fixes #167
The resume function forgot the by-ref params, so a lazy assignment hit the frame's copy of the address instead of the caller's variable. Fixes #177
… keep by-ref widening to untyped params Fixes #169
…d into fixed params and variadic, reflection invoke of variadics A pack of mixed args bound to a typed variadic is de-cellified at the call boundary; a spread ahead of a variadic no longer gets an eager empty pack; emitSpreadFill packs the tail for the variadic; the free-function spread unmasks a cell operand; reflection trampolines forward variadics as one spread. By-ref invokeArgs stays open (#171 repro narrowed). Fixes #184 Fixes #186
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.
What
Two groups of fixes from the open-issue triage.
Zend-faithful errors instead of silent coercion
intparam or return (A null passed to a non-nullable int parameter is coerced to 0 instead of throwing TypeError. #172, A string from json_decode passed to an int parameter under strict_types does not throw TypeError. #84),mixedarithmetic on array/non-numeric string (Adding an int to an empty string held in a mixed value returns the int instead of throwing TypeError. #147), object/enum/array as array key (An enum used as an array key does not throw TypeError #37),new ArrayIterator(scalar)(new ArrayIterator(1) does not throw TypeError. #83)str_repeatwith a negative count (str_repeat() with a negative count returns "" instead of throwing ValueError. #82)Crashes and invalid IR
tryrestores the backtrace depth of the current resume (A try inside a generator restores the backtrace depth saved at try entry. The generator is #90),$o->arr[] = yield($o->arr[] = yield 1;emits invalid IR #19),return yield from(return yield fromemits invalid IR #60)$m->f($n)on a mixed receiver where one implementer takes $n by value and another by-ref SIGSEGVs #16), spread of a cell pack (A dynamic method call that spreads a mixed argument pack into an in-scope private method segfaults. #168), closure rebound across a loop back-edge (A closure that captures the previous closure and calls a dynamic method on its result segfaults from the second link on. #167),Closure::fromCallableof a run-time callable (Closure::fromCallable with a function name only known at run time returns a closure that crashes when called. #170)var_dumpof a Closure (var_dump of a Closure object segfaults instead of dumping it #179), set-hook onReflectionProperty::setValue(ReflectionProperty::setValue on a property with a set hook segfaults. #169)<>operator (The<>operator is a parse error #33),use function X as alias(use function name as aliasis not resolved: calling the alias throws "Call to undefined function" #180)property_existssees dynamic props (property_exists() answers false for a dynamic property of a stdClass, numeric name or not. #120)New syntax is accepted by the compiler but not used in
src/(two-step rule).Known limits
f()->m()and$a->b->m()need the receiver hoisted into a temp.declare(strict_types=1).Still open
invokeArgs(..., [&$a])and A by-ref argument fed from a spread lands in a throwaway slot #61 (by-ref param fed from a spread) need ref-cell array elements.Verification
bin/buildclean, preflight "No errors found", CELLGUARD violations=0xfail.sh: 0 XPASSFixes #164 #122 #121 #126 #120 #184 #186 #18 #16 #19 #33 #37 #60 #82 #83 #84 #90 #140 #142 #147 #148 #163 #167 #168 #169 #170 #172 #175 #177 #179 #180
Not fixed here (stay open): #115 (no "uninitialized" state for typed props, needs an ABI sentinel), #78 and #34 (dynamic-property lvalue chains / ref binding). The property array of an erased plain-object foreach is not released after the loop (small bounded leak per loop).