Skip to content

Editorial: Centralize strictness-determination for function definitions#1563

Merged
ljharb merged 1 commit intotc39:masterfrom
jmdyck:function-strictness
Jun 17, 2019
Merged

Editorial: Centralize strictness-determination for function definitions#1563
ljharb merged 1 commit intotc39:masterfrom
jmdyck:function-strictness

Conversation

@jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented May 31, 2019

Formerly, for every different form of function definition, we would ask whether:

the function code for the function definition is strict mode code

and then pass the result to *FunctionCreate, and from there to FunctionAllocate.

Instead, we can equivalently ask whether:

the source text of the function definition's body is strict mode code.

The thing is, this question can be asked for all function definitions in one place: FunctionInitialize.

So do that, and drop the strict parameter from FunctionAllocate. (In #1562, I said we could eliminate one of the parameters: this is it.)


Downstream effect:
HTML has one call to FunctionCreate, whose signature is changed by this PR. The value that it passes to the Strict parameter is the same as what would be determined by FunctionInitialize, so dropping that argument (and step 8 that sets it) would preserve semantics. (Note that step 8 has HTML's only references to 'Directive Prologue' and 'Use Strict Directive', so those could then be dropped from its "terms used" list.)

@jmdyck
Copy link
Collaborator Author

jmdyck commented Jun 17, 2019

(force-pushed to resolve merge conflicts)

@ljharb ljharb self-assigned this Jun 17, 2019
Formerly, for every different form of function definition,
we would ask whether:
    the function code for the function definition is strict mode code
and then pass the result to *FunctionCreate,
and from there to FunctionAllocate.

Instead, we can equivalently ask whether:
    the source text of the function definition's body is strict mode code.
The thing is, *this* question can be asked for all function definitions
in one place: FunctionInitialize.

So do that, and drop the _strict_ parameter from FunctionAllocate.
@ljharb ljharb force-pushed the function-strictness branch from de231cf to 3bc01d4 Compare June 17, 2019 05:46
@ljharb ljharb merged commit 3bc01d4 into tc39:master Jun 17, 2019
@jmdyck jmdyck deleted the function-strictness branch June 17, 2019 12:55
jmdyck added a commit to jmdyck/html that referenced this pull request Jun 17, 2019
In the ECMAScript spec, the recently merged [PR whatwg#1563](tc39/ecma262#1563)
dropped the 'Strict' parameter from the abstract operation FunctionCreate
(since its setting can be determined from the 'Body' parameter).

Make the corresponding change to HTML's only call to FunctionCreate.
And delete the step that sets up the 'strict' variable.
And, since that step had the only references to "Directive Prologue" and
"Use Strict Directive", remove those from the "JavaScript terms used" list.
domenic pushed a commit to whatwg/html that referenced this pull request Jun 19, 2019
In the ECMAScript spec, the recently-merged
tc39/ecma262#1563 dropped the 'Strict'
parameter from the abstract operation FunctionCreate (since its setting
can be determined from the 'Body' parameter).

This commit makes the corresponding change to HTML's only call to
FunctionCreate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants