Skip to content

Commit 3b7c7fc

Browse files
committed
Deploying to main from @ openqasm/openqasm@76872e1 🚀
1 parent 0204188 commit 3b7c7fc

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

_sources/language/types.rst.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ declares a reference to a quantum bit. These qubits are referred
6565
to as "virtual qubits" (in distinction to "physical qubits" on
6666
actual hardware; see below). The statement ``qubit[size] name;``
6767
declares a quantum register with ``size`` qubits.
68-
Sizes must always be :ref:`compile-time constant <const-expression>` positive
68+
Sizes must always be :ref:`compile-time constant <const-expression>` non-negative
6969
integers.
7070
Quantum registers cannot be resized after declaration.
7171

@@ -237,6 +237,7 @@ There are n-bit signed and unsigned integers. The statements ``int[size] name;``
237237
signed 1:n-1:0 and unsigned 0:n:0 integers of the given size. The sizes
238238
and the surrounding brackets can be omitted (*e.g.* ``int name;``) to use
239239
a precision that is specified by the particular target architecture.
240+
If provided, the ``size`` of an integer must be at least 1.
240241
Bit-level operations cannot be used on types without a specified width, and
241242
unspecified-width types are different to *all* specified-width types for
242243
the purposes of casting.
@@ -310,8 +311,8 @@ multiplication and division by unsigned integers is defined by standard
310311
unsigned-integer arithmetic, with more details found in :ref:`the section on
311312
classical instructions <classical-instructions>`.
312313

313-
The statement ``angle[size] name;`` statement declares a new angle called
314-
``name`` with ``size`` bits in its representation. Angles can be assigned
314+
The statement ``angle[size] name;`` declares a new angle called
315+
``name`` with ``size`` bits in its representation, where ``size`` must be a positive integer. Angles can be assigned
315316
values using the constant ``π`` or ``pi``, such as::
316317

317318
// Declare a 20-bit angle with the value of "π/2"
@@ -805,6 +806,8 @@ and for multi-dimensional arrays subarray accesses can be specified using a
805806
comma-delimited list of indices (*e.g.* ``myArr[1, 2, 3]``), with the outer
806807
dimension specified first.
807808

809+
One or more dimension(s) of an array can be zero, in which case the array has size zero. An array of size zero cannot be indexed, e.g. given ``array[float[32], 0] myArray;``, it is an error to access either ``myArray[0]`` or ``myArray[-1]``.
810+
808811
Assignment to elements of arrays, as in the examples above, acts as expected,
809812
with the left-hand side of the assignment operating as a reference, thereby
810813
updating the values inside the original array. For multi-dimensional arrays,

grammar/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ <h1>OpenQASM 3.0 Grammar<a class="headerlink" href="#openqasm-3-0-grammar" title
210210
<span class="linenos">164</span><span class="nl">measureExpression</span><span class="p">:</span><span class="w"> </span><span class="no">MEASURE</span><span class="w"> </span><span class="nv">gateOperand</span><span class="p">;</span>
211211
<span class="linenos">165</span><span class="nl">rangeExpression</span><span class="p">:</span><span class="w"> </span><span class="nv">expression</span><span class="o">?</span><span class="w"> </span><span class="no">COLON</span><span class="w"> </span><span class="nv">expression</span><span class="o">?</span><span class="w"> </span><span class="o">(</span><span class="no">COLON</span><span class="w"> </span><span class="nv">expression</span><span class="o">)?</span><span class="p">;</span>
212212
<span class="linenos">166</span><span class="nl">setExpression</span><span class="p">:</span><span class="w"> </span><span class="no">LBRACE</span><span class="w"> </span><span class="nv">expression</span><span class="w"> </span><span class="o">(</span><span class="no">COMMA</span><span class="w"> </span><span class="nv">expression</span><span class="o">)*</span><span class="w"> </span><span class="no">COMMA</span><span class="o">?</span><span class="w"> </span><span class="no">RBRACE</span><span class="p">;</span>
213-
<span class="linenos">167</span><span class="nl">arrayLiteral</span><span class="p">:</span><span class="w"> </span><span class="no">LBRACE</span><span class="w"> </span><span class="o">(</span><span class="nv">expression</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nv">arrayLiteral</span><span class="o">)</span><span class="w"> </span><span class="o">(</span><span class="no">COMMA</span><span class="w"> </span><span class="o">(</span><span class="nv">expression</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nv">arrayLiteral</span><span class="o">))*</span><span class="w"> </span><span class="no">COMMA</span><span class="o">?</span><span class="w"> </span><span class="no">RBRACE</span><span class="p">;</span>
213+
<span class="linenos">167</span><span class="nl">arrayLiteral</span><span class="p">:</span><span class="w"> </span><span class="no">LBRACE</span><span class="w"> </span><span class="o">((</span><span class="nv">expression</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nv">arrayLiteral</span><span class="o">)</span><span class="w"> </span><span class="o">(</span><span class="no">COMMA</span><span class="w"> </span><span class="o">(</span><span class="nv">expression</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nv">arrayLiteral</span><span class="o">))*</span><span class="w"> </span><span class="no">COMMA</span><span class="o">?)?</span><span class="w"> </span><span class="no">RBRACE</span><span class="p">;</span>
214214
<span class="linenos">168</span>
215215
<span class="linenos">169</span><span class="c">// The general form is a comma-separated list of indexing entities.</span>
216216
<span class="linenos">170</span><span class="c">// `setExpression` is only valid when being used as a single index: registers</span>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ <h1>OpenQASM Live Specification<a class="headerlink" href="#openqasm-version-spe
133133
</li>
134134
<li class="toctree-l1"><a class="reference internal" href="grammar/index.html">OpenQASM 3.0 Grammar</a></li>
135135
<li class="toctree-l1"><a class="reference internal" href="release_notes.html">Release Notes</a><ul>
136-
<li class="toctree-l2"><a class="reference internal" href="release_notes.html#spec-v3-1-0-21">spec/v3.1.0-21</a><ul>
136+
<li class="toctree-l2"><a class="reference internal" href="release_notes.html#spec-v3-1-0-22">spec/v3.1.0-22</a><ul>
137137
<li class="toctree-l3"><a class="reference internal" href="release_notes.html#new-features">New Features</a></li>
138138
<li class="toctree-l3"><a class="reference internal" href="release_notes.html#upgrade-notes">Upgrade Notes</a></li>
139139
<li class="toctree-l3"><a class="reference internal" href="release_notes.html#bug-fixes">Bug Fixes</a></li>

language/types.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ <h3>Qubits<a class="headerlink" href="#qubits" title="Link to this heading">¶</
8484
to as “virtual qubits” (in distinction to “physical qubits” on
8585
actual hardware; see below). The statement <code class="docutils literal notranslate"><span class="pre">qubit[size]</span> <span class="pre">name;</span></code>
8686
declares a quantum register with <code class="docutils literal notranslate"><span class="pre">size</span></code> qubits.
87-
Sizes must always be <a class="reference internal" href="#const-expression"><span class="std std-ref">compile-time constant</span></a> positive
87+
Sizes must always be <a class="reference internal" href="#const-expression"><span class="std std-ref">compile-time constant</span></a> non-negative
8888
integers.
8989
Quantum registers cannot be resized after declaration.</p>
9090
<p>The label <code class="docutils literal notranslate"><span class="pre">name[j]</span></code> refers to a qubit of this register, where
@@ -225,6 +225,7 @@ <h3>Integers<a class="headerlink" href="#integers" title="Link to this heading">
225225
signed 1:n-1:0 and unsigned 0:n:0 integers of the given size. The sizes
226226
and the surrounding brackets can be omitted (<em>e.g.</em> <code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">name;</span></code>) to use
227227
a precision that is specified by the particular target architecture.
228+
If provided, the <code class="docutils literal notranslate"><span class="pre">size</span></code> of an integer must be at least 1.
228229
Bit-level operations cannot be used on types without a specified width, and
229230
unspecified-width types are different to <em>all</em> specified-width types for
230231
the purposes of casting.
@@ -286,8 +287,8 @@ <h3>Floating point numbers<a class="headerlink" href="#floating-point-numbers" t
286287
multiplication and division by unsigned integers is defined by standard
287288
unsigned-integer arithmetic, with more details found in <a class="reference internal" href="classical.html#classical-instructions"><span class="std std-ref">the section on
288289
classical instructions</span></a>.</p>
289-
<p>The statement <code class="docutils literal notranslate"><span class="pre">angle[size]</span> <span class="pre">name;</span></code> statement declares a new angle called
290-
<code class="docutils literal notranslate"><span class="pre">name</span></code> with <code class="docutils literal notranslate"><span class="pre">size</span></code> bits in its representation. Angles can be assigned
290+
<p>The statement <code class="docutils literal notranslate"><span class="pre">angle[size]</span> <span class="pre">name;</span></code> declares a new angle called
291+
<code class="docutils literal notranslate"><span class="pre">name</span></code> with <code class="docutils literal notranslate"><span class="pre">size</span></code> bits in its representation, where <code class="docutils literal notranslate"><span class="pre">size</span></code> must be a positive integer. Angles can be assigned
291292
values using the constant <code class="docutils literal notranslate"><span class="pre">π</span></code> or <code class="docutils literal notranslate"><span class="pre">pi</span></code>, such as:</p>
292293
<div class="highlight-qasm3 notranslate"><div class="highlight"><pre><span></span><span class="c1">// Declare a 20-bit angle with the value of &quot;π/2&quot;</span>
293294
<span class="kt">angle</span><span class="p">[</span><span class="m">20</span><span class="p">]</span><span class="w"> </span><span class="n">my_angle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="no">π</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="m">2</span><span class="p">;</span>
@@ -804,6 +805,7 @@ <h2>Literals<a class="headerlink" href="#literals" title="Link to this heading">
804805
and for multi-dimensional arrays subarray accesses can be specified using a
805806
comma-delimited list of indices (<em>e.g.</em> <code class="docutils literal notranslate"><span class="pre">myArr[1,</span> <span class="pre">2,</span> <span class="pre">3]</span></code>), with the outer
806807
dimension specified first.</p>
808+
<p>One or more dimension(s) of an array can be zero, in which case the array has size zero. An array of size zero cannot be indexed, e.g. given <code class="docutils literal notranslate"><span class="pre">array[float[32],</span> <span class="pre">0]</span> <span class="pre">myArray;</span></code>, it is an error to access either <code class="docutils literal notranslate"><span class="pre">myArray[0]</span></code> or <code class="docutils literal notranslate"><span class="pre">myArray[-1]</span></code>.</p>
807809
<p>Assignment to elements of arrays, as in the examples above, acts as expected,
808810
with the left-hand side of the assignment operating as a reference, thereby
809811
updating the values inside the original array. For multi-dimensional arrays,

objects.inv

2 Bytes
Binary file not shown.

release_notes.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
<section id="release-notes">
3636
<h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this heading"></a></h1>
37-
<section id="spec-v3-1-0-21">
38-
<span id="release-notes-spec-v3-1-0-21"></span><h2>spec/v3.1.0-21<a class="headerlink" href="#spec-v3-1-0-21" title="Link to this heading"></a></h2>
37+
<section id="spec-v3-1-0-22">
38+
<span id="release-notes-spec-v3-1-0-22"></span><h2>spec/v3.1.0-22<a class="headerlink" href="#spec-v3-1-0-22" title="Link to this heading"></a></h2>
3939
<section id="new-features">
40-
<span id="release-notes-spec-v3-1-0-21-new-features"></span><h3>New Features<a class="headerlink" href="#new-features" title="Link to this heading"></a></h3>
40+
<span id="release-notes-spec-v3-1-0-22-new-features"></span><h3>New Features<a class="headerlink" href="#new-features" title="Link to this heading"></a></h3>
4141
<ul class="simple">
4242
<li><p>The types <code class="docutils literal notranslate"><span class="pre">bool</span></code> and (scalar) <code class="docutils literal notranslate"><span class="pre">bit</span></code> are now explicitly described as being completely
4343
interchangeable in expression (r-value) positions, and that <code class="docutils literal notranslate"><span class="pre">bit</span></code> and <code class="docutils literal notranslate"><span class="pre">bit[1]</span></code> are distinct
@@ -49,7 +49,12 @@ <h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this
4949
</ul>
5050
</section>
5151
<section id="upgrade-notes">
52-
<span id="release-notes-spec-v3-1-0-21-upgrade-notes"></span><h3>Upgrade Notes<a class="headerlink" href="#upgrade-notes" title="Link to this heading"></a></h3>
52+
<span id="release-notes-spec-v3-1-0-22-upgrade-notes"></span><h3>Upgrade Notes<a class="headerlink" href="#upgrade-notes" title="Link to this heading"></a></h3>
53+
<ul class="simple">
54+
<li><p>It has been clarified that arrays and registers of size zero are
55+
allowed; however, integers and angles must have size greater than
56+
zero.</p></li>
57+
</ul>
5358
<ul class="simple">
5459
<li><p>The <code class="docutils literal notranslate"><span class="pre">qubit</span></code> type is no longer a valid base type for an <code class="docutils literal notranslate"><span class="pre">array</span></code>, and it is no longer stated
5560
that the register type <code class="docutils literal notranslate"><span class="pre">qubit[n]</span></code> is equivalent to an <code class="docutils literal notranslate"><span class="pre">array</span></code>; there is no need for these
@@ -58,7 +63,7 @@ <h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this
5863
</ul>
5964
</section>
6065
<section id="bug-fixes">
61-
<span id="release-notes-spec-v3-1-0-21-bug-fixes"></span><h3>Bug Fixes<a class="headerlink" href="#bug-fixes" title="Link to this heading"></a></h3>
66+
<span id="release-notes-spec-v3-1-0-22-bug-fixes"></span><h3>Bug Fixes<a class="headerlink" href="#bug-fixes" title="Link to this heading"></a></h3>
6267
<ul class="simple">
6368
<li><p>Some minor mathematical errors in the descriptions of the explicit gate
6469
actions in <a class="reference internal" href="language/standard_library.html#sdg" title="language/standard_library"><code class="xref oq oq-gate docutils literal notranslate"><span class="pre">sdg</span></code></a>, <a class="reference internal" href="language/standard_library.html#rx" title="language/standard_library"><code class="xref oq oq-gate docutils literal notranslate"><span class="pre">rx</span></code></a>, <a class="reference internal" href="language/standard_library.html#ry" title="language/standard_library"><code class="xref oq oq-gate docutils literal notranslate"><span class="pre">ry</span></code></a>, <a class="reference internal" href="language/standard_library.html#rz" title="language/standard_library"><code class="xref oq oq-gate docutils literal notranslate"><span class="pre">rz</span></code></a>, <a class="reference internal" href="language/standard_library.html#crx" title="language/standard_library"><code class="xref oq oq-gate docutils literal notranslate"><span class="pre">crx</span></code></a> and
@@ -91,7 +96,7 @@ <h3>Navigation</h3>
9196
<li class="toctree-l1"><a class="reference internal" href="language/index.html">Language</a></li>
9297
<li class="toctree-l1"><a class="reference internal" href="grammar/index.html">OpenQASM 3.0 Grammar</a></li>
9398
<li class="toctree-l1 current"><a class="current reference internal" href="#">Release Notes</a><ul>
94-
<li class="toctree-l2"><a class="reference internal" href="#spec-v3-1-0-21">spec/v3.1.0-21</a><ul>
99+
<li class="toctree-l2"><a class="reference internal" href="#spec-v3-1-0-22">spec/v3.1.0-22</a><ul>
95100
<li class="toctree-l3"><a class="reference internal" href="#new-features">New Features</a></li>
96101
<li class="toctree-l3"><a class="reference internal" href="#upgrade-notes">Upgrade Notes</a></li>
97102
<li class="toctree-l3"><a class="reference internal" href="#bug-fixes">Bug Fixes</a></li>

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)