-
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
CreateImmutableBinding called with only one argument #1824
Comments
https://tc39.es/ecma262/#sec-declarative-environment-records-createimmutablebinding-n-s does implicitly assert that the arg is a Boolean and not optional, but only cares if it’s true. This seems like a good thing to tighten up, but not a spec bug persay. |
I don't understand how it can be not a spec bug. The spec violates its own consistency rules, and so is not well formed. |
What i mean is, i can’t conceive how anybody could have implemented it incorrectly, since “false” and “not present” (implicitly undefined for abstract ops, per spec) are both not “true”. |
Agreed.
Citation? That's for functions, not abstract ops. And even if there were such a rule, it wouldn't apply, because there's nothing to indicate that CreateImmutableBinding's second parameter is optional. |
Right, that’s what needs fixing - either adding the false or making it optional. On reflection i see that it is indeed a spec bug. |
In the ES6 spec Table 15 said that the second argument to CreateImmutableBinding is optional and defaults to false |
I don't see any reason to complexify internal-only operations with optional parameters. Are there any others? |
There’s a few, but in this case it seems clear that the reintroductions were based on a spec that predates the change to make it required, so the bug was in making them optional. We should just add the missing falses, i think. |
What are the other internal-only operations with optional parameters? |
I see. Yes, in general worth it. Thanks. |
For some background, I believe that originally CreateImmutableBinding only had one argument and that the second argument was added to support a special case that was identified later. I don't recall specifically, but that special case probably only had a single "call site" that need to trigger it with the second argument. In that case I would have made it optional to avoid churn in algorithms that already used the one argument form (partially to minimize spec maintanance over head and partially to avoid signalling implementors that there was a meaningful change to the existing algorithms). Given the existing world of multiple proposal streams, multiple implementations, and multiple editors I would think that such churn issues would be an even bigger concern. |
I'm inclined to agree, especially when omitting the argument has a semantics that could easily and briefly be supplied explicitly instead (e.g., an empty list). But I don't feel strongly enough to propose de-optionalizing the ones we currently have.
I think this is a complete list (25):
(There's also the direction parameter for some definitions of regex evaluation, which is an odd case.) |
Some of these optional parameters help contain the invariants of an operation. For example GetExportedNames and ResolveExport required passing in an empty list at the top-level call. The recursive nature of those operations is not really of any concern to the caller, so making the parameter optional helps keep details encapsulated. |
Good point. Though I think those two are the only ops for which that argument applies. |
I'm in favour of refactoring out the optional parameters wherever it is reasonable to do so. |
At https://tc39.es/ecma262/#sec-asyncgenerator-definitions-evaluation
and https://tc39.es/ecma262/#sec-async-function-definitions-runtime-semantics-evaluation
for the Async*Expression cases where there's a Bindingidentifier, step 5 is
By analogy with FunctionExpression https://tc39.es/ecma262/#sec-function-definitions-runtime-semantics-evaluation and GeneratorExpression https://tc39.es/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluation It should be
The text was updated successfully, but these errors were encountered: