-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial: Introduce IsStrict() abstract operation #3209
Conversation
I like this mainly for having a good way to find the locations where strict mode code is being tested. This should establish the editorial convention that we use |
force-pushed to drop the last commit, as it's been superseded by PR #3210. |
(The pre-existing "IsStrict" AO is renamed to "ScriptIsStrict".)
(The pre-existing "IsStrict" AO is renamed to "ScriptIsStrict".)
I've broken it out into
65 commits in case that helps review.commit 1:
Rename the existing SDO "IsStrict" to "ScriptIsStrict", because it's specific to Scripts, and I want the general name for the general operation.
commit 2:
The algorithms in the spec have 7 occurrences of:
and 22 occurrences of:
This commit changes all of the former to the latter.
It isn't obvious whether or not this is a trivial change.
At first, I thought it was non-trivial, with the following reasoning: Clearly, you can have islands of strict mode code (SMC) within a sea of non-SMC. So, for such an island, it seems like it is SMC, but it's not contained in SMC, it's contained in non-SMC. (And so, this commit's change might cause the conditions to admit cases they currently don't, when X is SMC but isn't contained in SMC.)
However, consider test262's
language/statements/function/name-eval-strict-body.js
, which is basically:which throws a SyntaxError because (roughly speaking) 'eval' isn't allowed as the name of a strict mode function.
In more detail:
The
[noStrict]
means that the global code is non-SMC.The 'use strict' means that the source text matched by:
are all SMC.
The relevant early error rule is from 13.1.1 Static Semantics: Early Errors, for
BindingIdentifier : Identifier
:So in order for this error to apply, we must conclude that the source text matched by
BindingIdentifier
is contained in SMC. We can readily agree that it is SMC, but "contained in" is trickier: iseval
contained ineval
? Or maybe the idea is thateval
is part of all the SMC associated with the function decl.Anyhow, it seems like, as far as the spec is concerned, "is contained in SMC" means the same as "is SMC",
commit #3:
Normally, we say "the source text matched by X is strict mode code", but 3 spots leave out "the source text matched by". I think that's just a mistake, so this commit inserts the missing text.
commit #4:
With the relevant pseudocode mostly consistified, introduce the IsStrict() abstract operation.
commit #5:
Change:
to just:
commit #6: [Dropped Oct 28]
IsStrict(this production)
sounds odd, like it's asking whether a production is strict. So this commit changes such usages to
IsStrict(this |Foo|)
where possible (i.e., when the associated productions have only one LHS symbol), and to
IsStrict(this phrase)
otherwise.