Browse Source

handle a => a at top level – fixes #403

gh-438-b
Rich-Harris 9 years ago
parent
commit
aae8a09649
  1. 2
      src/ast/isReference.js
  2. 3
      test/function/top-level-arrow-function/_config.js
  3. 2
      test/function/top-level-arrow-function/main.js

2
src/ast/isReference.js

@ -4,6 +4,8 @@ export default function isReference ( node, parent ) {
}
if ( node.type === 'Identifier' ) {
if ( !parent ) return true;
// TODO is this right?
if ( parent.type === 'MemberExpression' ) return parent.computed || node === parent.object;

3
test/function/top-level-arrow-function/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'handles naked return value from top-level arrow function expression (#403)'
};

2
test/function/top-level-arrow-function/main.js

@ -0,0 +1,2 @@
const f = a => a;
assert.equal( f( 42 ), 42 );
Loading…
Cancel
Save