match_nested.carbon 483 B

123456789101112131415161718192021
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. package ExplorerTest api;
  7. // Test matching of a tuple inside a tuple.
  8. fn Main() -> i32 {
  9. var t: auto = ((1, 2), (3, 4));
  10. match (t) {
  11. case ((a: auto, b: auto), c: auto) => {
  12. return a - b + c[0] - c[1] + 2;
  13. }
  14. }
  15. return 1;
  16. }
  17. // CHECK:STDOUT: result: 0