Files
carbon-lang/explorer/testdata/choice/generic_choice_simple_assignment.carbon
T
pmqtt f957d4d87d Feature generic choice (#2042)
Implementation of generic choices!

I hope it is useful!
2022-08-24 11:30:04 -07:00

31 lines
779 B
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s
// CHECK: result: 22
package ExplorerTest api;
choice MyOptionalElement(ZZ:! Type) {
None(ZZ),
Element(ZZ)
}
fn Main() -> i32 {
var f: MyOptionalElement(i32);
f = MyOptionalElement(i32).None(22);
match(f) {
case MyOptionalElement(i32).None(var x: i32) => {
return x;
}
}
return 0;
}