Skip to content

Commit

Permalink
[spec] more tightly describe name processing
Browse files Browse the repository at this point in the history
Fixes #2. Closes #3. Closes #4. Closes #6.
  • Loading branch information
ljharb committed Jan 16, 2023
1 parent 8c3dcc9 commit 392abf2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
22 changes: 19 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@
});
let sdoMap = JSON.parse(`{}`);
let biblio = JSON.parse(`{"refsByClause":{"sec-well-known-intrinsic-objects":["_ref_0"],"sec-getintrinsic":["_ref_1"]},"entries":[{"type":"term","term":"Object Type","refId":"sec-object-type"},{"type":"table","id":"table-well-known-intrinsic-objects","number":1,"caption":"Table 1: Well-Known Intrinsic Objects","referencingIds":["_ref_0"]},{"type":"clause","id":"sec-well-known-intrinsic-objects","titleHTML":"Well-Known Intrinsic Objects","number":"6.1.7.4"},{"type":"clause","id":"sec-object-type","title":"The Object Type","titleHTML":"The <dfn variants=\\"is an Object,is not an Object\\">Object Type</dfn>","number":"6.1.7"},{"type":"clause","id":"sec-ecmascript-language-types","titleHTML":"ECMAScript Language Types","number":"6.1"},{"type":"op","aoid":"Type","refId":"sec-ecmascript-data-types-and-values"},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6","referencingIds":["_ref_1"]},{"type":"term","term":"%getIntrinsic%","refId":"sec-getintrinsic"},{"type":"clause","id":"sec-getintrinsic","title":"getIntrinsic ( name )","titleHTML":"getIntrinsic ( <var>name</var> )","number":"19.3.2"},{"type":"term","term":"%isFinite%","refId":"sec-isfinite-number"},{"type":"clause","id":"sec-isfinite-number","title":"isFinite ( number )","titleHTML":"isFinite ( <var>number</var> )","number":"19.3.3"},{"type":"clause","id":"sec-function-properties-of-the-global-object","titleHTML":"Function Properties of the Global Object","number":"19.3"},{"type":"clause","id":"sec-value-properties-of-the-global-object","titleHTML":"Value Properties of the Global Object","number":"19"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright &amp; Software License","number":"A"}]}`);
let biblio = JSON.parse(`{"refsByClause":{"sec-well-known-intrinsic-objects":["_ref_0"],"sec-getintrinsic":["_ref_1","_ref_2","_ref_3","_ref_4","_ref_5","_ref_6","_ref_7"]},"entries":[{"type":"term","term":"Object Type","refId":"sec-object-type"},{"type":"table","id":"table-well-known-intrinsic-objects","number":1,"caption":"Table 1: Well-Known Intrinsic Objects","referencingIds":["_ref_0"]},{"type":"clause","id":"sec-well-known-intrinsic-objects","titleHTML":"Well-Known Intrinsic Objects","number":"6.1.7.4"},{"type":"clause","id":"sec-object-type","title":"The Object Type","titleHTML":"The <dfn variants=\\"is an Object,is not an Object\\">Object Type</dfn>","number":"6.1.7","referencingIds":["_ref_3","_ref_4","_ref_5","_ref_6","_ref_7"]},{"type":"clause","id":"sec-ecmascript-language-types","titleHTML":"ECMAScript Language Types","number":"6.1"},{"type":"op","aoid":"Type","refId":"sec-ecmascript-data-types-and-values"},{"type":"clause","id":"sec-ecmascript-data-types-and-values","titleHTML":"ECMAScript Data Types and Values","number":"6","referencingIds":["_ref_1"]},{"type":"op","aoid":"SplitIntrinsicPath","refId":"sec-split-intrinsic-path"},{"type":"clause","id":"sec-split-intrinsic-path","title":"SplitIntrinsicPath ( path )","titleHTML":"SplitIntrinsicPath ( <var>path</var> )","number":"7.5.1","referencingIds":["_ref_2"]},{"type":"clause","id":"sec-miscellaneous","titleHTML":"Miscellaneous","number":"7.5"},{"type":"clause","id":"sec-abstract-operations","titleHTML":"Abstract Operations","number":"7"},{"type":"term","term":"%getIntrinsic%","refId":"sec-getintrinsic"},{"type":"clause","id":"sec-getintrinsic","title":"getIntrinsic ( name )","titleHTML":"getIntrinsic ( <var>name</var> )","number":"19.3.2"},{"type":"term","term":"%isFinite%","refId":"sec-isfinite-number"},{"type":"clause","id":"sec-isfinite-number","title":"isFinite ( number )","titleHTML":"isFinite ( <var>number</var> )","number":"19.3.3"},{"type":"clause","id":"sec-function-properties-of-the-global-object","titleHTML":"Function Properties of the Global Object","number":"19.3"},{"type":"clause","id":"sec-value-properties-of-the-global-object","titleHTML":"Value Properties of the Global Object","number":"19"},{"type":"clause","id":"sec-copyright-and-software-license","title":"Copyright & Software License","titleHTML":"Copyright &amp; Software License","number":"A"}]}`);
;let usesMultipage = false</script><style>body {
display: flex;
word-wrap: break-word;
Expand Down Expand Up @@ -2523,7 +2523,7 @@
</ul></div><div id="menu-toggle"><svg xmlns="http:https://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120">
<title>Menu</title>
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-ecmascript-data-types-and-values" title="ECMAScript Data Types and Values"><span class="secnum">6</span> ECMAScript Data Types and Values</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-ecmascript-language-types" title="ECMAScript Language Types"><span class="secnum">6.1</span> ECMAScript Language Types</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-object-type" title="The Object Type"><span class="secnum">6.1.7</span> The <dfn variants="is an Object,is not an Object">Object Type</dfn></a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-well-known-intrinsic-objects" title="Well-Known Intrinsic Objects"><span class="secnum">6.1.7.4</span> Well-Known Intrinsic Objects</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-value-properties-of-the-global-object" title="Value Properties of the Global Object"><span class="secnum">19</span> Value Properties of the Global Object</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-function-properties-of-the-global-object" title="Function Properties of the Global Object"><span class="secnum">19.3</span> Function Properties of the Global Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-getintrinsic" title="getIntrinsic ( name )"><span class="secnum">19.3.2</span> getIntrinsic ( <var>name</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-isfinite-number" title="isFinite ( number )"><span class="secnum">19.3.3</span> isFinite ( <var>number</var> )</a></li></ol></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / January 16, 2023</h1><h1 class="title">Get Intrinsic</h1>
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-ecmascript-data-types-and-values" title="ECMAScript Data Types and Values"><span class="secnum">6</span> ECMAScript Data Types and Values</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-ecmascript-language-types" title="ECMAScript Language Types"><span class="secnum">6.1</span> ECMAScript Language Types</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-object-type" title="The Object Type"><span class="secnum">6.1.7</span> The <dfn variants="is an Object,is not an Object">Object Type</dfn></a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-well-known-intrinsic-objects" title="Well-Known Intrinsic Objects"><span class="secnum">6.1.7.4</span> Well-Known Intrinsic Objects</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-abstract-operations" title="Abstract Operations"><span class="secnum">7</span> Abstract Operations</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-miscellaneous" title="Miscellaneous"><span class="secnum">7.5</span> Miscellaneous</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-split-intrinsic-path" title="SplitIntrinsicPath ( path )"><span class="secnum">7.5.1</span> SplitIntrinsicPath ( <var>path</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-value-properties-of-the-global-object" title="Value Properties of the Global Object"><span class="secnum">19</span> Value Properties of the Global Object</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-function-properties-of-the-global-object" title="Function Properties of the Global Object"><span class="secnum">19.3</span> Function Properties of the Global Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-getintrinsic" title="getIntrinsic ( name )"><span class="secnum">19.3.2</span> getIntrinsic ( <var>name</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-isfinite-number" title="isFinite ( number )"><span class="secnum">19.3.3</span> isFinite ( <var>number</var> )</a></li></ol></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / January 16, 2023</h1><h1 class="title">Get Intrinsic</h1>

<emu-clause number="6" id="sec-ecmascript-data-types-and-values" aoid="Type">
<h1><span class="secnum">6</span> ECMAScript Data Types and Values</h1>
Expand Down Expand Up @@ -2586,6 +2586,21 @@ <h1><span class="secnum">6.1.7.4</span> Well-Known Intrinsic Objects</h1>
</emu-clause>
</emu-clause>

<emu-clause id="sec-abstract-operations" number="7">
<h1><span class="secnum">7</span> Abstract Operations</h1>

<emu-clause id="sec-miscellaneous" number="5">
<h1><span class="secnum">7.5</span> Miscellaneous</h1>

<emu-clause id="sec-split-intrinsic-path" type="abstract operation" aoid="SplitIntrinsicPath">
<h1><span class="secnum">7.5.1</span> SplitIntrinsicPath ( <var>path</var> )</h1>
<p>The abstract operation SplitIntrinsicPath takes argument <var>path</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of either Strings or Symbols, or a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
<p><code>SplitIntrinsicPath</code> takes a path like <code>a.b.c</code> or <code>a.b[Symbol.c]</code>, and splits it into a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> containing each part.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">This algorithm may be more simply expressed as a parsing grammar, but for now I went with this approach.</div></emu-note>
<emu-alg><ol><li>Let <var>parts</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>index</var> be 0.</li><li>Let <var>len</var> be the length of <var>path</var>.</li><li>While <var>index</var> &lt; <var>len</var>,<ol><li>Let <var>dotOrBracket</var> be the index into <var>path</var>, starting at <var>index</var>, that contains either <emu-val>"."</emu-val> or <emu-val>"["</emu-val>.</li><li>If <var>dotOrBracket</var> = <var>index</var>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If !&nbsp;<emu-xref aoid="Get"><a href="https://tc39.es/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>path</var>, <var>dotOrBracket</var>) is <emu-val>"."</emu-val>, then<ol><li>Let <var>part</var> be the <emu-xref href="#substring"><a href="https://tc39.es/ecma262/#substring">substring</a></emu-xref> of <var>path</var> from <var>index</var> to <var>dotOrBracket</var>.</li><li>Let <var>index</var> be <var>dotOrBracket</var> + 1.</li><li>If <var>part</var> is <emu-val>""</emu-val> or <emu-val>"__proto__"</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>part</var> is <emu-val>"constructor"</emu-val> or <emu-val>"name"</emu-val> or <emu-val>"length"</emu-val>, and <var>index</var> &gt;e; <var>len</var>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Append <var>part</var> to <var>parts</var>.</li></ol></li><li>Else,<ol><li>Let <var>closeBracket</var> be the index into <var>path</var>, starting at <var>dotOrBracket</var>, that contains <emu-val>"]"</emu-val>.</li><li>If <var>closeBracket</var> is -1, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>part</var> be the <emu-xref href="#substring"><a href="https://tc39.es/ecma262/#substring">substring</a></emu-xref> of <var>path</var> from <var>dotOrBracket</var> + 1 to <var>closeBracket</var>.</li><li>If <var>part</var> does not match the [[Description]] column of any row in <emu-xref href="#table-well-known-symbols"><a href="https://tc39.es/ecma262/#table-well-known-symbols">Table 1</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>symbol</var> be the value that matches the [[Description]] column in <emu-xref href="#table-well-known-symbols"><a href="https://tc39.es/ecma262/#table-well-known-symbols">Table 1</a></emu-xref>.</li><li>Let <var>index</var> be <var>closeBracket</var> + 1.</li><li>If <var>index</var> &lt; <var>len</var>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Append <var>symbol</var> to <var>parts</var>.</li></ol></li></ol></li><li>Return <var>parts</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-value-properties-of-the-global-object" number="19">
<h1><span class="secnum">19</span> Value Properties of the Global Object</h1>

Expand All @@ -2596,7 +2611,7 @@ <h1><span class="secnum">19.3</span> Function Properties of the Global Object</h
<h1><span class="secnum">19.3.2</span> getIntrinsic ( <var>name</var> )</h1>
<ins class="block">
<p>The <code>getIntrinsic</code> function is the <dfn>%getIntrinsic%</dfn> intrinsic object. When the <code>getIntrinsic</code> function is called with one argument <var>name</var>, the following steps are taken:</p>
<emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_1"><a href="#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>name</var>) is not String, throw a <emu-val>TypeError</emu-val> exception.</li><li>If the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>"%"</emu-val>, <var>name</var>, and <emu-val>"%"</emu-val> would match an intrinsic according to the notation described in <a href="https://tc39.es/ecma262/#sec-well-known-intrinsic-objects">Well-Known Intrinsic Objects</a>, and that intrinsic is listed as being "Directly Accessible to ECMAScript Code", then<ol><li>Return that intrinsic.</li></ol></li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></emu-alg>
<emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_1"><a href="#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>name</var>) is not String, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>kind</var> be <emu-const>data</emu-const>.</li><li>If <var>name</var> starts with "get ",<ol><li>Let <var>kind</var> be <emu-const>getter</emu-const>.</li></ol></li><li>Else if <var>name</var> starts with "set ",<ol><li>Let <var>kind</var> be <emu-const>setter</emu-const>.</li></ol></li><li>If <var>kind</var> is not <emu-const>data</emu-const>, then<ol><li>Let <var>name</var> be the <emu-xref href="#substring"><a href="https://tc39.es/ecma262/#substring">substring</a></emu-xref> of <var>name</var> from 4.</li></ol></li><li>Let <var>parts</var> be ?&nbsp;<emu-xref aoid="SplitIntrinsicPath" id="_ref_2"><a href="#sec-split-intrinsic-path">SplitIntrinsicPath</a></emu-xref>(<var>name</var>).</li><li>If the <emu-xref href="#string-concatenation"><a href="https://tc39.es/ecma262/#string-concatenation">string-concatenation</a></emu-xref> of <emu-val>"%"</emu-val>, <var>name</var>, and <emu-val>"%"</emu-val> would match an intrinsic according to the notation described in <a href="https://tc39.es/ecma262/#sec-well-known-intrinsic-objects">Well-Known Intrinsic Objects</a>, and that intrinsic is listed as being "Directly Accessible to ECMAScript Code", then<ol><li>If <var>kind</var> is <emu-const>data</emu-const>, and the intrinsic describes a <emu-xref href="#sec-object-type" id="_ref_3"><a href="#sec-object-type">data property</a></emu-xref>,<ol><li>Return that intrinsic.</li></ol></li><li>Else if <var>kind</var> is <emu-const>getter</emu-const>, and the intrinsic describes an <emu-xref href="#sec-object-type" id="_ref_4"><a href="#sec-object-type">accessor property</a></emu-xref>,<ol><li>Return that <emu-xref href="#sec-object-type" id="_ref_5"><a href="#sec-object-type">accessor property</a></emu-xref>’s [[Get]] function.</li></ol></li><li>Else if <var>kind</var> is <emu-const>setter</emu-const>, and the intrinsic describes an <emu-xref href="#sec-object-type" id="_ref_6"><a href="#sec-object-type">accessor property</a></emu-xref>,<ol><li>Return that <emu-xref href="#sec-object-type" id="_ref_7"><a href="#sec-object-type">accessor property</a></emu-xref>’s [[Set]] function.</li></ol></li></ol></li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
When the <var>name</var> string succeeds in producing an intrinsic, the <var>name</var> string surrounded by <emu-val>"%"</emu-val> matches the intrinsic notation described in the specification in <a href="https://tc39.es/ecma262/#sec-well-known-intrinsic-objects">Well-Known Intrinsic Objects</a>.
</div></emu-note>
Expand Down Expand Up @@ -2629,4 +2644,5 @@ <h2>Software License</h2>
<p>THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>

</emu-annex>

</div></body>
Loading

0 comments on commit 392abf2

Please sign in to comment.