Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions compiler/lib/src/main/scala/analysis/Semantics/Type.scala
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,12 @@ object Type {
case (Boolean -> Boolean) => true
case _ => false
}
def string = pair match {
case (String(None) -> String(None)) => true
case (String(Some(e1)) -> String(Some(e2))) => e1 == e2
case _ => false
}
def sameDef = (t1.getDefNodeId, t2.getDefNodeId) match {
case (Some(id1), Some(id2)) => id1 == id2
case _ => false
}
numeric ||
boolean ||
string ||
sameDef
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/src/test/scala/semantics/TypeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class TypeSpec extends AnyWordSpec {
duplicate(I64),
duplicate(I8),
duplicate(Integer),
duplicate(String(None)),
duplicate(U16),
duplicate(U32),
duplicate(U64),
Expand All @@ -40,6 +39,7 @@ class TypeSpec extends AnyWordSpec {
(defaultAbsType, defaultEnum),
(defaultArray, defaultStruct),
(Boolean,String(None)),
duplicate(String(None)),
(F32,F64),
(I8,U32),
duplicate(AnonArray(None, I32)),
Expand Down
49 changes: 24 additions & 25 deletions docs/fpp-spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -10884,14 +10884,28 @@ <h3 id="Types_String-Types">17.6. String Types</h3>
A string type is written <code>string</code> or <code>string size</code> <em>n</em>,
where <em>n</em> is an integer value in the range [1,2^31-1].
There is one string type <code>string</code> and one string type <code>string size</code> <em>n</em>
for each legal value of <em>n</em>.</p>
for each legal value of <em>n</em>.
The string type names map to the string types in the following way:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The type name <code>string</code> maps to the type <code>string</code>.</p>
</li>
<li>
<p>The type name <code>string</code> <code>size</code> <em>e</em> maps to the type <code>string</code> <code>size</code> <em>n</em>,
after evaluating the expression <em>e</em> to the value <em>n</em>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The value <em>n</em>, if present, is called the <strong>size</strong> associated with the string
type.
The size provides a maximum string length that the code generator can use
The size provides a maximum string length that the code generator uses
for allocating memory and serializing data.
If no explicit size is present, then the code generator uses a default size.</p>
If no size is present, then the code generator uses
the <a href="#Definitions_Framework-Definitions_Constant-Definitions">framework definition</a> <code>FW_FIXED_LENGTH_STRING_SIZE</code> as the
maximum string length.</p>
</div>
</div>
<div class="sect2">
Expand Down Expand Up @@ -11560,11 +11574,6 @@ <h3 id="Type-Checking_Identical-Types">18.13. Identical Types</h3>
<a href="#Types_The-Boolean-Type">the Boolean type</a>.</p>
</li>
<li>
<p>\$T_1\$ and \$T_2\$
are both the same
<a href="#Types_String-Types">string type</a>.</p>
</li>
<li>
<p>Each of \$T_1\$ and \$T_2\$
is an
<a href="#Types_Abstract-Types">abstract type</a>,
Expand All @@ -11576,6 +11585,9 @@ <h3 id="Type-Checking_Identical-Types">18.13. Identical Types</h3>
</li>
</ol>
</div>
<div class="paragraph">
<p>Note that string types are never identical.</p>
</div>
</div>
<div class="sect2">
<h3 id="Type-Checking_Type-Conversion">18.14. Type Conversion</h3>
Expand Down Expand Up @@ -12040,8 +12052,7 @@ <h2 id="Values">20. Values</h2>
<div class="paragraph">
<p>Every value <em>v</em> belongs to exactly one <a href="#Types_Canonical-Types">canonical type</a>
<em>T</em>, except that
every string value belongs to the type <code>string</code> and to
all types <code>string size</code> <em>n</em>, for any <em>n</em>.</p>
every string value belongs to every string type.</p>
</div>
<div class="paragraph">
<p>Every value that belongs to type <em>T</em> also belongs to every
Expand Down Expand Up @@ -12137,20 +12148,8 @@ <h3 id="Values_String-Values">20.5. String Values</h3>
characters in the sequence.</p>
</div>
<div class="paragraph">
<p>A string value <em>v</em> belongs to the following canonical types:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>string</code></p>
</li>
<li>
<p><code>string size</code> <em>n</em> for any <em>n</em>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Note that <em>v</em> may have length <em>m</em> and type <code>string size</code> <em>n</em>,
<p>A string value <em>v</em> belongs to every string type.
Note that <em>v</em> may have length <em>m</em> and type <code>string size</code> <em>n</em>,
with \$m &gt; n\$.
In this case, the behavior is defined by the code generation strategy.
In particular, when code is generated for the F Prime framework,
Expand Down Expand Up @@ -12861,7 +12860,7 @@ <h3 id="Analysis-and-Translation_Translation-Tools">23.4. Translation Tools</h3>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2026-03-09 15:31:20 -0700
Last updated 2026-03-09 16:24:44 -0700
</div>
</div>
<script src="code-prettify/run_prettify.js"></script>
Expand Down
6 changes: 2 additions & 4 deletions docs/spec/Type-Checking.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ the type.
are both
<<Types_The-Boolean-Type,the Boolean type>>.

. stem:[T_1] and stem:[T_2]
are both the same
<<Types_String-Types,string type>>.

. Each of stem:[T_1] and stem:[T_2]
is an
<<Types_Abstract-Types,abstract type>>,
Expand All @@ -282,6 +278,8 @@ is an
<<Types_Struct-Types,struct type>>,
and both types refer to the same definition.

Note that string types are never identical.

=== Type Conversion

We say that a type stem:[T_1] *may be converted to* another type stem:[T_2] if
Expand Down
13 changes: 11 additions & 2 deletions docs/spec/Types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,21 @@ A string type is written `string` or `string size` _n_,
where _n_ is an integer value in the range [1,2^31-1].
There is one string type `string` and one string type `string size` _n_
for each legal value of _n_.
The string type names map to the string types in the following way:

* The type name `string` maps to the type `string`.

* The type name `string` `size` _e_ maps to the type `string` `size` _n_,
after evaluating the expression _e_ to the value _n_.

The value _n_, if present, is called the *size* associated with the string
type.
The size provides a maximum string length that the code generator can use
The size provides a maximum string length that the code generator uses
for allocating memory and serializing data.
If no explicit size is present, then the code generator uses a default size.
If no size is present, then the code generator uses
the <<Definitions_Framework-Definitions_Constant-Definitions,
framework definition>> `FW_FIXED_LENGTH_STRING_SIZE` as the
maximum string length.

=== Array Types

Expand Down
10 changes: 2 additions & 8 deletions docs/spec/Values.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ A *value* is one of the following:

Every value _v_ belongs to exactly one <<Types_Canonical-Types,canonical type>>
_T_, except that
every string value belongs to the type `string` and to
all types `string size` _n_, for any _n_.
every string value belongs to every string type.

Every value that belongs to type _T_ also belongs to every
<<Types_Alias-Types,alias type>> whose
Expand Down Expand Up @@ -96,12 +95,7 @@ e.g., `"abc"`.
Every string value _v_ has a *length*, which is the number of
characters in the sequence.

A string value _v_ belongs to the following canonical types:

* `string`

* `string size` _n_ for any _n_.

A string value _v_ belongs to every string type.
Note that _v_ may have length _m_ and type `string size` _n_,
with stem:[m > n].
In this case, the behavior is defined by the code generation strategy.
Expand Down