Skip to content
Permalink
Browse files

Disallow nullable Promise types. (#248)

  • Loading branch information
Tobie Langel
Tobie Langel committed Dec 9, 2016
1 parent c50ffc4 commit 7366419820e871db6792fd4e7407d490cdaa8020
Showing with 42 additions and 29 deletions.
  1. +12 −9 index.bs
  2. +30 −20 index.html
@@ -5256,8 +5256,8 @@ type.

<pre class="grammar" id="prod-NonAnyType">
NonAnyType :
PromiseType ε
PrimitiveType Null
PromiseType Null
StringType Null
identifier Null
"sequence" "&lt;" Type "&gt;" Null
@@ -5768,16 +5768,17 @@ from an existing type (called the <dfn id="dfn-inner-type" export>inner type</df
which just allows the additional value <emu-val>null</emu-val>
to be a member of its set of values. [=Nullable types=]
are represented in IDL by placing a <span class="char">U+003F QUESTION MARK ("?")</span>
character after an existing type. The inner type must not
be {{any}},
another nullable type, or a [=union type=]
that itself has [=includes a nullable type=]
or has a dictionary or record type as one of its
[=flattened member types=].
character after an existing type.
The inner type must not be:

* {{any}},
* a [=Promise type=],
* another nullable type, or
* a [=union type=] that itself has [=includes a nullable type=]
or has a dictionary or record type as one of its [=flattened member types=].

Note: Although dictionary and record types can in general be nullable,
they cannot when used
as the type of an operation argument or a dictionary member.
they cannot when used as the type of an operation argument or a dictionary member.

Nullable type constant values in IDL are represented in the same way that
constant values of their [=inner type=]
@@ -5885,6 +5886,8 @@ result of an asynchronous operation”.
See <a href="https://tc39.github.io/ecma262/#sec-promise-objects">section 25.4</a>
of the ECMAScript specification for details on the semantics of promise objects.

Promise types are non-nullable, but |T| may be nullable.

There is no way to represent a promise value in IDL.

The [=type name=] of a promise type
@@ -5540,8 +5540,8 @@ <h3 class="heading settled" data-level="2.11" id="idl-types"><span class="secno"
ε
</pre>
<pre class="grammar" id="prod-NonAnyType">NonAnyType :
PromiseType ε
PrimitiveType Null
PromiseType Null
StringType Null
identifier Null
"sequence" "&lt;" Type ">" Null
@@ -5856,12 +5856,20 @@ <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-level="2.11.22"
<h4 class="heading settled" data-level="2.11.23" id="idl-nullable-type"><span class="secno">2.11.23. </span><span class="content">Nullable types — <var>T</var>?</span><a class="self-link" href="#idl-nullable-type"></a></h4>
<p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" id="dfn-nullable-type">nullable type</dfn> is an IDL type constructed
from an existing type (called the <dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" id="dfn-inner-type">inner type</dfn>),
which just allows the additional value <emu-val>null</emu-val> to be a member of its set of values. <a data-link-type="dfn" href="#dfn-nullable-type" id="ref-for-dfn-nullable-type-12">Nullable types</a> are represented in IDL by placing a <span class="char">U+003F QUESTION MARK ("?")</span> character after an existing type. The inner type must not
be <code class="idl"><a data-link-type="idl" href="#idl-any" id="ref-for-idl-any-6">any</a></code>,
another nullable type, or a <a data-link-type="dfn" href="#dfn-union-type" id="ref-for-dfn-union-type-11">union type</a> that itself has <a data-link-type="dfn" href="#dfn-includes-a-nullable-type" id="ref-for-dfn-includes-a-nullable-type-3">includes a nullable type</a> or has a dictionary or record type as one of its <a data-link-type="dfn" href="#dfn-flattened-union-member-types" id="ref-for-dfn-flattened-union-member-types-5">flattened member types</a>.</p>
which just allows the additional value <emu-val>null</emu-val> to be a member of its set of values. <a data-link-type="dfn" href="#dfn-nullable-type" id="ref-for-dfn-nullable-type-12">Nullable types</a> are represented in IDL by placing a <span class="char">U+003F QUESTION MARK ("?")</span> character after an existing type.
The inner type must not be:</p>
<ul>
<li data-md="">
<p><code class="idl"><a data-link-type="idl" href="#idl-any" id="ref-for-idl-any-6">any</a></code>,</p>
<li data-md="">
<p>a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-3">Promise type</a>,</p>
<li data-md="">
<p>another nullable type, or</p>
<li data-md="">
<p>a <a data-link-type="dfn" href="#dfn-union-type" id="ref-for-dfn-union-type-11">union type</a> that itself has <a data-link-type="dfn" href="#dfn-includes-a-nullable-type" id="ref-for-dfn-includes-a-nullable-type-3">includes a nullable type</a> or has a dictionary or record type as one of its <a data-link-type="dfn" href="#dfn-flattened-union-member-types" id="ref-for-dfn-flattened-union-member-types-5">flattened member types</a>.</p>
</ul>
<p class="note" role="note">Note: Although dictionary and record types can in general be nullable,
they cannot when used
as the type of an operation argument or a dictionary member.</p>
they cannot when used as the type of an operation argument or a dictionary member.</p>
<p>Nullable type constant values in IDL are represented in the same way that
constant values of their <a data-link-type="dfn" href="#dfn-inner-type" id="ref-for-dfn-inner-type-5">inner type</a> would be represented, or with the <emu-t>null</emu-t> token.</p>
<p>The <a data-link-type="dfn" href="#dfn-type-name" id="ref-for-dfn-type-name-23">type name</a> of a nullable type
@@ -5926,6 +5934,7 @@ <h4 class="heading settled dfn-paneled idl-code" data-dfn-type="interface" data-
for the eventual results of a deferred (and possibly asynchronous) computation
result of an asynchronous operation”.
See <a href="https://tc39.github.io/ecma262/#sec-promise-objects">section 25.4</a> of the ECMAScript specification for details on the semantics of promise objects.</p>
<p>Promise types are non-nullable, but <var>T</var> may be nullable.</p>
<p>There is no way to represent a promise value in IDL.</p>
<p>The <a data-link-type="dfn" href="#dfn-type-name" id="ref-for-dfn-type-name-26">type name</a> of a promise type
is the concatenation of the type name for <var>T</var> and
</table>
</div>
<h4 class="heading settled" data-level="3.2.20" id="es-promise"><span class="secno">3.2.20. </span><span class="content">Promise types — Promise&lt;<var>T</var>></span><a class="self-link" href="#es-promise"></a></h4>
<p>IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-3">promise type</a> values are
<p>IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-4">promise type</a> values are
represented by ECMAScript <emu-val>Promise</emu-val> objects.</p>
<div class="algorithm" data-algorithm="convert an ECMAScript value to promise" id="es-to-promise">
<p>An ECMAScript value <var>V</var> is <a data-link-type="dfn" href="#dfn-convert-ecmascript-to-idl-value" id="ref-for-dfn-convert-ecmascript-to-idl-value-32">converted</a> to an IDL <a class="idl-code" data-link-type="interface" href="#idl-promise" id="ref-for-idl-promise-1">Promise<var>T</var></a> value as follows:</p>
<li data-md="">
<p>Let <var>promise</var> be the result of calling <var>resolve</var> with <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-promise-constructor">%Promise%</a> as the <emu-val>this</emu-val> value and <var>V</var> as the single argument value.</p>
<li data-md="">
<p>Return the IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-4">promise type</a> value that is a reference to the
<p>Return the IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-5">promise type</a> value that is a reference to the
same object as <var>promise</var>.</p>
</ol>
</div>
<p id="promise-to-es"> The result of <a data-link-type="dfn" href="#dfn-convert-idl-to-ecmascript-value" id="ref-for-dfn-convert-idl-to-ecmascript-value-31">converting</a> an IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-5">promise type</a> value to an ECMAScript
<p id="promise-to-es"> The result of <a data-link-type="dfn" href="#dfn-convert-idl-to-ecmascript-value" id="ref-for-dfn-convert-idl-to-ecmascript-value-31">converting</a> an IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-6">promise type</a> value to an ECMAScript
value is the <emu-val>Promise</emu-val> value that represents a reference to the same object that the
IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-6">promise type</a> represents. </p>
IDL <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-7">promise type</a> represents. </p>
<div class="algorithm" data-algorithm="perform some steps once a promise is settled">
<p>One can <dfn data-dfn-type="dfn" data-export="" data-lt="upon settling" id="dfn-perform-steps-once-promise-is-settled">perform some steps once a promise is settled<a class="self-link" href="#dfn-perform-steps-once-promise-is-settled"></a></dfn>.
There can be one or two sets of steps to perform,
<p>The [<code class="idl"><a data-link-type="idl" href="#NewObject" id="ref-for-NewObject-4">NewObject</a></code>]
extended attribute must not
be used on anything other than a <a data-link-type="dfn" href="#dfn-regular-operation" id="ref-for-dfn-regular-operation-10">regular</a> or <a data-link-type="dfn" href="#dfn-static-operation" id="ref-for-dfn-static-operation-8">static</a> <a data-link-type="dfn" href="#dfn-operation" id="ref-for-dfn-operation-41">operation</a> whose <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-4">return type</a> is an <a data-link-type="dfn" href="#idl-interface" id="ref-for-idl-interface-11">interface type</a> or
a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-7">promise type</a>.</p>
a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-8">promise type</a>.</p>
<div class="example" id="example-245e5507">
<a class="self-link" href="#example-245e5507"></a>
<p>As an example, this extended attribute is suitable for use on
<p>And then, if an exception was thrown:</p>
<ol>
<li data-md="">
<p>If <var>op</var> has a <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-5">return type</a> that is a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-8">promise type</a>, then:</p>
<p>If <var>op</var> has a <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-5">return type</a> that is a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-9">promise type</a>, then:</p>
<ol>
<li data-md="">
<p>Let <var>reject</var> be the initial value of <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-promise-constructor">%Promise%</a>.reject.</p>
<li data-md="">
<p>If <var>completion</var> is a normal completion, return <var>completion</var>.</p>
<li data-md="">
<p>If <var>completion</var> is an abrupt completion and the operation has a <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-7">return type</a> that is <em>not</em> a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-9">promise type</a>, return <var>completion</var>.</p>
<p>If <var>completion</var> is an abrupt completion and the operation has a <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-7">return type</a> that is <em>not</em> a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-10">promise type</a>, return <var>completion</var>.</p>
<li data-md="">
<p>Let <var>reject</var> be the initial value of <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-promise-constructor">%Promise%</a>.reject.</p>
<li data-md="">
<li data-md="">
<p>If <var>completion</var> is a normal completion, return <var>completion</var>.</p>
<li data-md="">
<p>If <var>completion</var> is an abrupt completion and the attribute’s type is <em>not</em> a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-10">promise type</a>, return <var>completion</var>.</p>
<p>If <var>completion</var> is an abrupt completion and the attribute’s type is <em>not</em> a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-11">promise type</a>, return <var>completion</var>.</p>
<li data-md="">
<p>Let <var>reject</var> be the initial value of <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-promise-constructor">%Promise%</a>.reject.</p>
<li data-md="">
<li data-md="">
<p>If <var>completion</var> is a normal completion, return <var>completion</var>.</p>
<li data-md="">
<p>If <var>completion</var> is an abrupt completion and the callback function has a <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-8">return type</a> that is <em>not</em> a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-11">promise type</a>, return <var>completion</var>.</p>
<p>If <var>completion</var> is an abrupt completion and the callback function has a <a data-link-type="dfn" href="#dfn-return-type" id="ref-for-dfn-return-type-8">return type</a> that is <em>not</em> a <a data-link-type="dfn" href="#dfn-promise-type" id="ref-for-dfn-promise-type-12">promise type</a>, return <var>completion</var>.</p>
<li data-md="">
<p>Let <var>reject</var> be the initial value of <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-promise-constructor">%Promise%</a>.reject.</p>
<li data-md="">
<ul>
<li><a href="#ref-for-dfn-promise-type-1">2.2.4.1. Legacy callers</a>
<li><a href="#ref-for-dfn-promise-type-2">2.2.6. Overloading</a>
<li><a href="#ref-for-dfn-promise-type-3">3.2.20. Promise types — Promise&lt;T></a> <a href="#ref-for-dfn-promise-type-4">(2)</a> <a href="#ref-for-dfn-promise-type-5">(3)</a> <a href="#ref-for-dfn-promise-type-6">(4)</a>
<li><a href="#ref-for-dfn-promise-type-7">3.3.11. [NewObject]</a>
<li><a href="#ref-for-dfn-promise-type-8">3.6.7. Operations</a>
<li><a href="#ref-for-dfn-promise-type-9">3.10. User objects implementing callback interfaces</a> <a href="#ref-for-dfn-promise-type-10">(2)</a>
<li><a href="#ref-for-dfn-promise-type-11">3.11. Invoking callback functions</a>
<li><a href="#ref-for-dfn-promise-type-3">2.11.23. Nullable types — T?</a>
<li><a href="#ref-for-dfn-promise-type-4">3.2.20. Promise types — Promise&lt;T></a> <a href="#ref-for-dfn-promise-type-5">(2)</a> <a href="#ref-for-dfn-promise-type-6">(3)</a> <a href="#ref-for-dfn-promise-type-7">(4)</a>
<li><a href="#ref-for-dfn-promise-type-8">3.3.11. [NewObject]</a>
<li><a href="#ref-for-dfn-promise-type-9">3.6.7. Operations</a>
<li><a href="#ref-for-dfn-promise-type-10">3.10. User objects implementing callback interfaces</a> <a href="#ref-for-dfn-promise-type-11">(2)</a>
<li><a href="#ref-for-dfn-promise-type-12">3.11. Invoking callback functions</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dfn-union-type">

0 comments on commit 7366419

Please sign in to comment.
You can’t perform that action at this time.