Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rollup/rollup into sync-a…
Browse files Browse the repository at this point in the history
…6448b99
  • Loading branch information
docschina-bot committed Sep 28, 2023
2 parents 324b77f + a6448b9 commit 9ad7f33
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# rollup changelog
# rollup changelog

## 3.29.4

_2023-09-28_

### Bug Fixes

- Fix static analysis when an exported function uses callbacks (#5158)

### Pull Requests

- [#5158](https://github.com/rollup/rollup/pull/5158): Deoptimize all parameters when losing track of a function (@lukastaegert)

## 3.29.3

Expand Down
2 changes: 1 addition & 1 deletion browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/browser",
"version": "3.29.3",
"version": "3.29.4",
"description": "Next-generation ES module bundler browser build",
"main": "dist/rollup.browser.js",
"module": "dist/es/rollup.browser.js",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "3.29.3",
"version": "3.29.4",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/es/rollup.js",
Expand Down
7 changes: 6 additions & 1 deletion src/ast/nodes/shared/FunctionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ export default abstract class FunctionBase extends NodeBase {
this.getObjectEntity().deoptimizePath(path);
if (path.length === 1 && path[0] === UnknownKey) {
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
// which means the return expression needs to be reassigned
// which means the return expression and parameters need to be reassigned
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
for (const parameterList of this.scope.parameters) {
for (const parameter of parameterList) {
parameter.deoptimizePath(UNKNOWN_PATH);
}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/function/samples/mutate-via-parameter/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const assert = require('node:assert');

module.exports = defineTest({
description:
'respects variable mutations via unknown parameter values if we lose track of a function',
exports({ test }) {
assert.ok(test(state => (state.modified = true)));
}
});
8 changes: 8 additions & 0 deletions test/function/samples/mutate-via-parameter/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function test(callback) {
const state = {
modified: false
};
callback(state);
if (state.modified) return true;
return false;
}

1 comment on commit 9ad7f33

@vercel
Copy link

@vercel vercel bot commented on 9ad7f33 Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.