mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1030263 - Make top-level let declarations a syntax error in self-hosted code. r=till
--HG-- extra : rebase_source : c815d9ea118a0df6fed2b6bf4a0e11623fbf3a10
This commit is contained in:
parent
f77fe2a434
commit
f36b6bb901
@ -3622,6 +3622,25 @@ Parser<FullParseHandler>::letDeclaration()
|
||||
JS_ASSERT(pc->staticScope == stmt->staticScope);
|
||||
} else {
|
||||
if (pc->atBodyLevel()) {
|
||||
/*
|
||||
* When bug 589199 is fixed, let variables will be stored in
|
||||
* the slots of a new scope chain object, encountered just
|
||||
* before the global object in the overall chain. This extra
|
||||
* object is present in the scope chain for all code in that
|
||||
* global, including self-hosted code. But self-hosted code
|
||||
* must be usable against *any* global object, including ones
|
||||
* with other let variables -- variables possibly placed in
|
||||
* conflicting slots. Forbid top-level let declarations to
|
||||
* prevent such conflicts from ever occurring.
|
||||
*/
|
||||
if (options().selfHostingMode &&
|
||||
!pc->sc->isFunctionBox() &&
|
||||
stmt == pc->topScopeStmt)
|
||||
{
|
||||
report(ParseError, false, null(), JSMSG_SELFHOSTED_TOP_LEVEL_LET);
|
||||
return null();
|
||||
}
|
||||
|
||||
/*
|
||||
* ES4 specifies that let at top level and at body-block scope
|
||||
* does not shadow var, so convert back to var.
|
||||
|
@ -242,7 +242,7 @@ MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 188, 3, JSEXN_TYPEERR, "{0} {1} called on
|
||||
MSG_DEF(JSMSG_SYMBOL_TO_PRIMITIVE, 189, 0, JSEXN_TYPEERR, "can't convert symbol object to primitive")
|
||||
MSG_DEF(JSMSG_UNUSED190, 190, 0, JSEXN_NONE, "")
|
||||
MSG_DEF(JSMSG_BAD_INDEX, 191, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
|
||||
MSG_DEF(JSMSG_UNUSED192, 192, 0, JSEXN_NONE, "")
|
||||
MSG_DEF(JSMSG_SELFHOSTED_TOP_LEVEL_LET,192,0, JSEXN_SYNTAXERR, "self-hosted code cannot contain top-level 'let' declarations")
|
||||
MSG_DEF(JSMSG_BAD_FOR_EACH_LOOP, 193, 0, JSEXN_SYNTAXERR, "invalid for each loop")
|
||||
MSG_DEF(JSMSG_OBJECT_WATCH_DEPRECATED,194, 0, JSEXN_NONE, "Object.prototype.watch and unwatch are very slow, non-standard, and deprecated; use a getter/setter instead")
|
||||
MSG_DEF(JSMSG_TYPE_ERR_BAD_ARGS, 195, 0, JSEXN_TYPEERR, "invalid arguments")
|
||||
|
Loading…
Reference in New Issue
Block a user