// to the corresponding activation frame at runtime if necessary.
// For instance declarations inside an eval scope need to be added
// to the calling function context.
- if (top_scope_->is_function_scope()) {
+ // Similarly, strict mode eval scope does not leak variable declarations to
+ // the caller's scope so we declare all locals, too.
+ if (top_scope_->is_function_scope() ||
+ top_scope_->is_strict_mode_eval_scope()) {
// Declare the variable in the function scope.
var = top_scope_->LocalLookup(name);
if (var == NULL) {
bool is_function_scope() const { return type_ == FUNCTION_SCOPE; }
bool is_global_scope() const { return type_ == GLOBAL_SCOPE; }
bool is_strict_mode() const { return strict_mode_; }
+ bool is_strict_mode_eval_scope() const {
+ return is_eval_scope() && is_strict_mode();
+ }
// Information about which scopes calls eval.
bool calls_eval() const { return scope_calls_eval_; }
assertEquals(test(i), true);
}
})();
+
+
+(function TestStrictModeEval() {
+ "use strict";
+ eval("var eval_local = 10;");
+ assertThrows(function() { return eval_local; }, ReferenceError);
+})();