Browse Source

handle top-level blocks – fixes #326

gh-335
Rich-Harris 9 years ago
parent
commit
5210386bd2
  1. 2
      src/ast/attachScopes.js
  2. 3
      test/function/top-level-block/_config.js
  3. 3
      test/function/top-level-block/main.js

2
src/ast/attachScopes.js

@ -44,7 +44,7 @@ export default function attachScopes ( statement ) {
}
// create new block scope
if ( node.type === 'BlockStatement' && !/Function/.test( parent.type ) ) {
if ( node.type === 'BlockStatement' && ( !parent || !/Function/.test( parent.type ) ) ) {
newScope = new Scope({
parent: scope,
block: true

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

@ -0,0 +1,3 @@
module.exports = {
description: 'allows top-level block'
};

3
test/function/top-level-block/main.js

@ -0,0 +1,3 @@
{
assert.equal( 1 + 1, 2 );
}
Loading…
Cancel
Save