File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
test/function/samples/mutate-via-parameter Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -74,8 +74,13 @@ export default abstract class FunctionBase extends NodeBase {
7474 this . getObjectEntity ( ) . deoptimizePath ( path ) ;
7575 if ( path . length === 1 && path [ 0 ] === UnknownKey ) {
7676 // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
77- // which means the return expression needs to be reassigned
77+ // which means the return expression and parameters need to be reassigned
7878 this . scope . getReturnExpression ( ) . deoptimizePath ( UNKNOWN_PATH ) ;
79+ for ( const parameterList of this . scope . parameters ) {
80+ for ( const parameter of parameterList ) {
81+ parameter . deoptimizePath ( UNKNOWN_PATH ) ;
82+ }
83+ }
7984 }
8085 }
8186
Original file line number Diff line number Diff line change 1+ const assert = require ( 'node:assert' ) ;
2+
3+ module . exports = defineTest ( {
4+ description :
5+ 'respects variable mutations via unknown parameter values if we lose track of a function' ,
6+ exports ( { test } ) {
7+ assert . ok ( test ( state => ( state . modified = true ) ) ) ;
8+ }
9+ } ) ;
Original file line number Diff line number Diff line change 1+ export function test ( callback ) {
2+ const state = {
3+ modified : false
4+ } ;
5+ callback ( state ) ;
6+ if ( state . modified ) return true ;
7+ return false ;
8+ }
You can’t perform that action at this time.
0 commit comments