mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 19:31:08 +01:00
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:
+4
-4
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user