Skip to content
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

Normative: Allow duplicate FunctionDeclarations in a block #453

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -36561,7 +36561,7 @@ <h1>Block-Level Function Declarations Web Legacy Compatibility Semantics</h1>
<p>A function is declared and only referenced within a single block</p>
<ul>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the NOTE formatting redundant? Previous discussion on this topic: #341 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that discussion. The key point seems to be, from @allenwb

However, the standards orgs kind of frown upon starting sections with long explicit NOTEs and would prefer that they be moved to follow the actual normative text. Basically, short non-normative content-free intro paragraph ok, starting with a long descriptive informative NOTE, less ok.

I'm curious as to the standards orgs' reasoning. W3C and WHATWG specs often put their non-normative sections in notes, even if they are introductory paragraphs. They use formatting which doesn't cause things to be indented as much, which reduces the overhead. But that's a discussion for another day, so I'll revert that part.

<li>
A |FunctionDeclaration| whose |BindingIdentifier| is the name _f_ occurs exactly once within the function code of an enclosing function _g_ and that declaration is nested within a |Block|.
One or more |FunctionDeclaration|s whose |BindingIdentifier| is the name _f_ occur within the function code of an enclosing function _g_ and that declaration is nested within a |Block|.
</li>
<li>
No other declaration of _f_ that is not a `var` declaration occurs within the function code of _g_
Expand All @@ -36575,7 +36575,7 @@ <h1>Block-Level Function Declarations Web Legacy Compatibility Semantics</h1>
<p>A function is declared and possibly used within a single |Block| but also referenced by an inner function definition that is not contained within that same |Block|.</p>
<ul>
<li>
A |FunctionDeclaration| whose |BindingIdentifier| is the name _f_ occurs exactly once within the function code of an enclosing function _g_ and that declaration is nested within a |Block|.
One or more |FunctionDeclaration|s whose |BindingIdentifier| is the name _f_ occur within the function code of an enclosing function _g_ and that declaration is nested within a |Block|.
</li>
<li>
No other declaration of _f_ that is not a `var` declaration occurs within the function code of _g_
Expand All @@ -36595,7 +36595,7 @@ <h1>Block-Level Function Declarations Web Legacy Compatibility Semantics</h1>
<p>A function is declared and possibly used within a single block but also referenced within subsequent blocks.</p>
<ul>
<li>
A |FunctionDeclaration| whose |BindingIdentifier| is the name _f_ occurs exactly once within the function code of an enclosing function _g_ and that declaration is nested within a |Block|.
One or more |FunctionDeclaration| whose |BindingIdentifier| is the name _f_ occur within the function code of an enclosing function _g_ and that declaration is nested within a |Block|.
</li>
<li>
No other declaration of _f_ that is not a `var` declaration occurs within the function code of _g_
Expand Down Expand Up @@ -36709,6 +36709,27 @@ <h1>Changes to EvalDeclarationInstantiation</h1>
1. Return NormalCompletion(~empty~).
</emu-alg>
</emu-annex>
<emu-annex id="sec-block-duplicates-allowed-static-semantics">
<h1>Changes to Block Static Semantics: Early Errors</h1>
<p>For web browser compatibility, that rule is modified with the addition of the <ins>highlighted</ins> text:</p>
<emu-grammar>Block : `{` StatementList `}`</emu-grammar>
<ul>
<li>
It is a Syntax Error if the LexicallyDeclaredNames of |StatementList| contains any duplicate entries, <ins>unless the source code matching this production is not strict mode code and the duplicate entries are only bound by FunctionDeclarations.</ins>
</li>
</ul>
</emu-annex>
<emu-annex id="sec-web-compat-blockdeclarationinstantiation">
<h1>Changes to BlockDeclarationInstantiation</h1>
<p>During BlockDeclarationInstantiation the following steps are performed in place of step 4.b.iii:</p>
<emu-alg>
1. If _envRec_.HasBinding(_fn_) is *true*, then
1. Assert: _d_ is a |FunctionDeclaration|.
1. _envRec_.SetMutableBinding(_fn_, _fo_, *false*).
1. Else,
1. Perform _envRec_.InitializeBinding(_fn_, _fo_).
</emu-alg>
</emu-annex>
</emu-annex>

<!-- es6num="B.3.4" -->
Expand Down