diff --git a/src/utils/testForSideEffects.js b/src/utils/testForSideEffects.js index 04a4cd7..a6219f3 100644 --- a/src/utils/testForSideEffects.js +++ b/src/utils/testForSideEffects.js @@ -24,7 +24,9 @@ export default function testForSideEffects ( node, scope, statement, strongDepen if ( isReference( node, parent ) ) { const flattened = flatten( node ); - if ( !scope.contains( flattened.name ) ) { + if ( flattened.name === 'arguments' ) { + hasSideEffect = true; + } if ( !scope.contains( flattened.name ) ) { const declaration = statement.module.trace( flattened.name ); if ( declaration && !declaration.isExternal ) { const module = declaration.module || declaration.statement.module; // TODO is this right? diff --git a/test/form/side-effect-k/_config.js b/test/form/side-effect-k/_config.js new file mode 100644 index 0000000..093b570 --- /dev/null +++ b/test/form/side-effect-k/_config.js @@ -0,0 +1,8 @@ +module.exports = { + solo: true, + show: true, + description: 'use of arguments is treated as a side-effect', + options: { + moduleName: 'myBundle' + } +}; diff --git a/test/form/side-effect-k/_expected/amd.js b/test/form/side-effect-k/_expected/amd.js new file mode 100644 index 0000000..85bce30 --- /dev/null +++ b/test/form/side-effect-k/_expected/amd.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + + +}); diff --git a/test/form/side-effect-k/_expected/cjs.js b/test/form/side-effect-k/_expected/cjs.js new file mode 100644 index 0000000..ad9a93a --- /dev/null +++ b/test/form/side-effect-k/_expected/cjs.js @@ -0,0 +1 @@ +'use strict'; diff --git a/test/form/side-effect-k/_expected/es6.js b/test/form/side-effect-k/_expected/es6.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-k/_expected/iife.js b/test/form/side-effect-k/_expected/iife.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-k/_expected/umd.js b/test/form/side-effect-k/_expected/umd.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-k/foo.js b/test/form/side-effect-k/foo.js new file mode 100644 index 0000000..e60ac33 --- /dev/null +++ b/test/form/side-effect-k/foo.js @@ -0,0 +1,19 @@ +export function augment ( x ) { + var prop, source; + + var i = arguments.length; + var sources = Array( i - 1 ); + while ( i-- ) { + sources[i-1] = arguments[i]; + } + + while (source = sources.shift()) { + for (prop in source) { + if (hasOwn.call(source, prop)) { + x[prop] = source[prop]; + } + } + } + + return x; +} diff --git a/test/form/side-effect-k/main.js b/test/form/side-effect-k/main.js new file mode 100644 index 0000000..bab1d82 --- /dev/null +++ b/test/form/side-effect-k/main.js @@ -0,0 +1,4 @@ +import { augment } from './foo.js'; + +export default function x () {} +augment( x.prototype );