Update executable semantics for choice to match final state of p0157 (#304)

* Make parentheses optional for alternatives with no arguments.

* Use `,` instead of `;` as separator for alternatives, and make the trailing separator optional.
This commit is contained in:
Geoff Romer
2021-02-26 13:12:09 -08:00
committed by GitHub
parent 29a59944fa
commit 853360345e
3 changed files with 20 additions and 8 deletions
+4 -4
View File
@@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
choice Ints {
None();
One(Int);
Two(Int,Int);
None,
One(Int),
Two(Int,Int)
}
fn main() -> Int {
@@ -13,7 +13,7 @@ fn main() -> Int {
var auto: y = Ints.One(42);
var auto: n = 0;
match (y) {
case Ints.None() =>
case Ints.None =>
n = n + 2;
case Ints.One(auto: x) =>
n = x + 1 - 42;
+1 -1
View File
@@ -9,7 +9,7 @@ var auto: x = Ints.None();
var auto: y = Ints.One(0 = 42);
var auto: n = 0;
match (y) {
case Ints.None() =>
case Ints.None =>
n = (n + 2);
case Ints.One(0 = auto: x) =>
n = ((x + 1) - 42);