fail_assign_to_empty.carbon 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/tuple/no_prelude/fail_assign_to_empty.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/no_prelude/fail_assign_to_empty.carbon
  10. // CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+4]]:13: error: cannot initialize tuple of 0 elements from tuple with 1 element [TupleInitElementCountMismatch]
  11. // CHECK:STDERR: var x: () = ((),);
  12. // CHECK:STDERR: ^~~~~
  13. // CHECK:STDERR:
  14. var x: () = ((),);
  15. // CHECK:STDOUT: --- fail_assign_to_empty.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  19. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  20. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type) [concrete]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  25. // CHECK:STDOUT: .x = %x
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: name_binding_decl {
  28. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  29. // CHECK:STDOUT: %.loc15_1: %pattern_type = var_pattern %x.patt [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  32. // CHECK:STDOUT: %.loc15_9.1: type = splice_block %.loc15_9.3 [concrete = constants.%empty_tuple.type] {
  33. // CHECK:STDOUT: %.loc15_9.2: %empty_tuple.type = tuple_literal ()
  34. // CHECK:STDOUT: %.loc15_9.3: type = converted %.loc15_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: fn @__global_init() {
  40. // CHECK:STDOUT: !entry:
  41. // CHECK:STDOUT: %.loc15_15: %empty_tuple.type = tuple_literal ()
  42. // CHECK:STDOUT: %.loc15_17: %tuple.type = tuple_literal (%.loc15_15)
  43. // CHECK:STDOUT: assign file.%x.var, <error>
  44. // CHECK:STDOUT: return
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: