port
6ac4de87a8b01500b066a3e401e921d2d84b42db
original commit message:
harmony-scoping: make assignment to 'const' a late error.
Per TC39 Nov 2014 decision. This patch also changes behavior for "legacy const":
assignments to sloppy const in strict mode is now also a type error. This fixes
v8:2243 and also brings us in compliance with other engines re assignment to function
names (see updated webkit test), but might have bigger implications. That change can
easily be reverted by changing Variable::IsSignallingAssignmentToConst.
BUG=
R=dslomov@chromium.org, weiliang.lin@intel.com
Review URL: https://codereview.chromium.org/
763033002
Patch from Chunyang Dai <chunyang.dai@intel.com>.
Cr-Commit-Position: refs/heads/master@{#25532}
__ CallRuntime(Runtime::kThrowReferenceError, 1);
__ bind(&assign);
EmitStoreToStackLocalOrContextSlot(var, location);
-
} else if (!var->is_const_mode() || op == Token::INIT_CONST) {
if (var->IsLookupSlot()) {
// Assignment to var.
}
EmitStoreToStackLocalOrContextSlot(var, location);
}
+ } else if (IsSignallingAssignmentToConst(var, op, strict_mode())) {
+ __ CallRuntime(Runtime::kThrowConstAssignError, 0);
}
- // Non-initializing assignments to consts are ignored.
}