Skip to content

Commit

Permalink
Normative: Disallow internal methods returning continue|break|return
Browse files Browse the repository at this point in the history
I.e., disallow internal methods from returning abrupt completions
with [[Type]] = continue or break or return.

Somewhat casually in 6.1.7.2, and then more formally in 6.1.7.3.

Resolves tc39#1537.
  • Loading branch information
jmdyck committed May 13, 2019
1 parent 552f203 commit fc51b84
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ <h1>Object Internal Methods and Internal Slots</h1>
<p><emu-xref href="#table-5"></emu-xref> summarizes the <em>essential internal methods</em> used by this specification that are applicable to all objects created or manipulated by ECMAScript code. Every object must have algorithms for all of the essential internal methods. However, all objects do not necessarily use the same algorithms for those methods.</p>
<p>The &ldquo;Signature&rdquo; column of <emu-xref href="#table-5"></emu-xref> and other similar tables describes the invocation pattern for each internal method. The invocation pattern always includes a parenthesized list of descriptive parameter names. If a parameter name is the same as an ECMAScript type name then the name describes the required type of the parameter value. If an internal method explicitly returns a value, its parameter list is followed by the symbol &ldquo;&rarr;&rdquo; and the type name of the returned value. The type names used in signatures refer to the types defined in clause <emu-xref href="#sec-ecmascript-data-types-and-values"></emu-xref> augmented by the following additional names. &ldquo;<em>any</em>&rdquo; means the value may be any ECMAScript language type.</p>
<p>In addition to its parameters, an internal method always has access to the object that is the target of the method invocation.</p>
<p>An internal method implicitly returns a Completion Record.</p>
<p>An internal method implicitly returns a Completion Record, either a normal completion that wraps a value of the return type shown in its invocation pattern, or a throw completion.</p>
<emu-table id="table-5" caption="Essential Internal Methods">
<table>
<tbody>
Expand Down Expand Up @@ -1540,10 +1540,19 @@ <h2>Definitions:</h2>
All references to <em>SameValue</em> are according to the definition of the SameValue algorithm.
</li>
</ul>
<h2>Return value:</h2>
<p>The value returned by any internal method must be a Completion Record with either:</p>
<ul>
<li>[[Type]] = ~normal~, [[Target]] = ~empty~, and [[Value]] = a value of the "normal return type" shown below for that internal method, or</li>
<li>[[Type]] = ~throw~, [[Target]] = ~empty~, and [[Value]] = any ECMAScript language value.</li>
</ul>
<emu-note>
<p>An internal method must not return a completion with [[Type]] = ~continue~, ~break~, or ~return~.</p>
</emu-note>
<h2>[[GetPrototypeOf]] ( )</h2>
<ul>
<li>
The Type of the return value must be either Object or Null.
The normal return type is either Object or Null.
</li>
<li>
If target is non-extensible, and [[GetPrototypeOf]] returns a value _V_, then any future calls to [[GetPrototypeOf]] should return the SameValue as _V_.
Expand All @@ -1555,7 +1564,7 @@ <h2>[[GetPrototypeOf]] ( )</h2>
<h2>[[SetPrototypeOf]] ( _V_ )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
If target is non-extensible, [[SetPrototypeOf]] must return *false*, unless _V_ is the SameValue as the target's observed [[GetPrototypeOf]] value.
Expand All @@ -1564,7 +1573,7 @@ <h2>[[SetPrototypeOf]] ( _V_ )</h2>
<h2>[[IsExtensible]] ( )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
If [[IsExtensible]] returns *false*, all future calls to [[IsExtensible]] on the target must return *false*.
Expand All @@ -1573,7 +1582,7 @@ <h2>[[IsExtensible]] ( )</h2>
<h2>[[PreventExtensions]] ( )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
If [[PreventExtensions]] returns *true*, all future calls to [[IsExtensible]] on the target must return *false* and the target is now considered non-extensible.
Expand All @@ -1582,7 +1591,7 @@ <h2>[[PreventExtensions]] ( )</h2>
<h2>[[GetOwnProperty]] ( _P_ )</h2>
<ul>
<li>
The Type of the return value must be either Property Descriptor or Undefined.
The normal return type is either Property Descriptor or Undefined.
</li>
<li>
If the Type of the return value is Property Descriptor, the return value must be a <emu-xref href="#sec-completepropertydescriptor">complete property descriptor</emu-xref>.
Expand All @@ -1606,7 +1615,7 @@ <h2>[[GetOwnProperty]] ( _P_ )</h2>
<h2>[[DefineOwnProperty]] ( _P_, _Desc_ )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
[[DefineOwnProperty]] must return *false* if _P_ has previously been observed as a non-configurable own property of the target, unless either:
Expand All @@ -1626,7 +1635,7 @@ <h2>[[DefineOwnProperty]] ( _P_, _Desc_ )</h2>
<h2>[[HasProperty]] ( _P_ )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
If _P_ was previously observed as a non-configurable own data or accessor property of the target, [[HasProperty]] must return *true*.
Expand All @@ -1635,7 +1644,7 @@ <h2>[[HasProperty]] ( _P_ )</h2>
<h2>[[Get]] ( _P_, _Receiver_ )</h2>
<ul>
<li>
The return value must be an ECMAScript language value.
The normal return type is any ECMAScript language type.
</li>
<li>
If _P_ was previously observed as a non-configurable, non-writable own data property of the target with value _V_, then [[Get]] must return the SameValue as _V_.
Expand All @@ -1647,7 +1656,7 @@ <h2>[[Get]] ( _P_, _Receiver_ )</h2>
<h2>[[Set]] ( _P_, _V_, _Receiver_ )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
If _P_ was previously observed as a non-configurable, non-writable own data property of the target, then [[Set]] must return *false* unless _V_ is the SameValue as _P_'s [[Value]] attribute.
Expand All @@ -1659,7 +1668,7 @@ <h2>[[Set]] ( _P_, _V_, _Receiver_ )</h2>
<h2>[[Delete]] ( _P_ )</h2>
<ul>
<li>
The Type of the return value must be Boolean.
The normal return type is Boolean.
</li>
<li>
If _P_ was previously observed as a non-configurable own data or accessor property of the target, [[Delete]] must return *false*.
Expand All @@ -1668,7 +1677,7 @@ <h2>[[Delete]] ( _P_ )</h2>
<h2>[[OwnPropertyKeys]] ( )</h2>
<ul>
<li>
The return value must be a List.
The normal return type is List.
</li>
<li>
The returned List must not contain any duplicate entries.
Expand All @@ -1686,13 +1695,13 @@ <h2>[[OwnPropertyKeys]] ( )</h2>
<h2>[[Call]] ( )</h2>
<ul>
<li>
The return value must be an ECMAScript language value.
The normal return type is any ECMAScript language type.
</li>
</ul>
<h2>[[Construct]] ( )</h2>
<ul>
<li>
The Type of the return value must be Object.
The normal return type is Object.
</li>
</ul>
</emu-clause>
Expand Down

0 comments on commit fc51b84

Please sign in to comment.