You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
921 B
JavaScript
27 lines
921 B
JavaScript
'use strict';
|
|
|
|
/*
|
|
special case: in a function...
|
|
if defaults: function param env + body declaration env
|
|
if no defaults: single shared env
|
|
this is to keep default-expressions from seeing the body-declared variables
|
|
|
|
* eval (effectively produces a function scope in strict mode, but a block scope in non-strict mode)
|
|
- for direct eval, parent scope is the calling scope
|
|
- for indirect eval, parent scope is the global scope
|
|
* Block
|
|
* for loop (including the iterator value!) - unique scope for each iteration?
|
|
* catch clause (for the error argument)
|
|
|
|
*/
|
|
|
|
module.exports = function createsBlockScope(node) {
|
|
return (
|
|
node.type === "BlockStatement" ||
|
|
node.type === "CatchClause" ||
|
|
node.type === "ForStatement" ||
|
|
/* The below is not quite correct; needs to take into consideration strict mode, whether it references global eval, etc. */
|
|
(node.type === "CallExpression" && node.callee.name === "eval")
|
|
);
|
|
};
|