Allow more operators on bool vectors (#24131)

* Sema: allow binary operations and boolean not on vectors of bool

* langref: Clarify use of operators on vectors (`and` and `or` not allowed)

closes #24093
This commit is contained in:
Daniel Kongsgaard
2025-06-13 00:16:23 +02:00
committed by GitHub
parent 4a02e080d1
commit 5e3c0b7af7
5 changed files with 79 additions and 50 deletions

View File

@@ -1926,8 +1926,10 @@ or
Vector types are created with the builtin function {#link|@Vector#}.
</p>
<p>
Vectors support the same builtin operators as their underlying base types.
These operations are performed element-wise, and return a vector of the same length
Vectors generally support the same builtin operators as their underlying base types.
The only exception to this is the keywords `and` and `or` on vectors of bools, since
these operators affect control flow, which is not allowed for vectors.
All other operations are performed element-wise, and return a vector of the same length
as the input vectors. This includes:
</p>
<ul>
@@ -1937,6 +1939,7 @@ or
<li>Bitwise operators ({#syntax#}>>{#endsyntax#}, {#syntax#}<<{#endsyntax#}, {#syntax#}&{#endsyntax#},
{#syntax#}|{#endsyntax#}, {#syntax#}~{#endsyntax#}, etc.)</li>
<li>Comparison operators ({#syntax#}<{#endsyntax#}, {#syntax#}>{#endsyntax#}, {#syntax#}=={#endsyntax#}, etc.)</li>
<li>Boolean not ({#syntax#}!{#endsyntax#})</li>
</ul>
<p>
It is prohibited to use a math operator on a mixture of scalars (individual numbers)