Skip to content

Commit

Permalink
Bind arrow function call parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 8, 2017
1 parent 382f5bd commit 4d1f946
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/ast/nodes/ArrowFunctionExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import Scope from '../scopes/Scope';
import ReturnValueScope from '../scopes/ReturnValueScope';

export default class ArrowFunctionExpression extends Node {
bindCallAtPath ( path, { args } ) {
if ( path.length === 0 ) {
this.scope.bindCallArguments( args );
}
}

bindNode () {
this.body.bindImplicitReturnExpressionToScope
? this.body.bindImplicitReturnExpressionToScope()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var assert = require( 'assert' );

module.exports = {
description: 'Associates arrow function parameters with their call arguments with regard to mutations',
exports: function ( exports ) {
assert.equal( exports.baz, 'present' );
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const foo = { noEffect: () => {} };
const bar = {};

const addEffect = obj => {
obj.noEffect = () => {
bar.baz = 'present';
};
};

addEffect( foo );
foo.noEffect();

export default bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const foo = { mightBeExported: {} };
const exported = {};

function assignExported ( obj ) {
obj.mightBeExported = exported;
}

assignExported( foo );
foo.mightBeExported.bar = 'present';

export default exported;
16 changes: 0 additions & 16 deletions test/function/samples/associate-parameter-mutations-2/main.js

This file was deleted.

0 comments on commit 4d1f946

Please sign in to comment.