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 {
74
74
this . getObjectEntity ( ) . deoptimizePath ( path ) ;
75
75
if ( path . length === 1 && path [ 0 ] === UnknownKey ) {
76
76
// 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
78
78
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
+ }
79
84
}
80
85
}
81
86
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