fail_assign_nested.carbon 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/fail_assign_nested.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/fail_assign_nested.carbon
  10. // CHECK:STDERR: fail_assign_nested.carbon:[[@LINE+3]]:36: error: cannot initialize tuple of 2 elements from tuple with 3 elements [TupleInitElementCountMismatch]
  11. // CHECK:STDERR: var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6));
  12. // CHECK:STDERR: ^~~~~~~~~
  13. var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6));
  14. // CHECK:STDOUT: --- fail_assign_nested.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  18. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  19. // CHECK:STDOUT: %tuple.type.471: type = tuple_type (%i32, %i32) [template]
  20. // CHECK:STDOUT: %tuple.type.c0a: type = tuple_type (%tuple.type.471, %tuple.type.471) [template]
  21. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  22. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  23. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  24. // CHECK:STDOUT: %tuple.type.37f: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [template]
  25. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template]
  26. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template]
  27. // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [template]
  28. // CHECK:STDOUT: %tuple.type.e89: type = tuple_type (%tuple.type.37f, %tuple.type.37f) [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: .Int = %import_ref.187
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/...
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .x = %x
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %x.var: ref %tuple.type.c0a = var x
  46. // CHECK:STDOUT: %x: ref %tuple.type.c0a = bind_name x, %x.var
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @__global_init() {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  52. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  53. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  54. // CHECK:STDOUT: %.loc14_44: %tuple.type.37f = tuple_literal (%int_1, %int_2, %int_3)
  55. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4]
  56. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5]
  57. // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [template = constants.%int_6]
  58. // CHECK:STDOUT: %.loc14_55: %tuple.type.37f = tuple_literal (%int_4, %int_5, %int_6)
  59. // CHECK:STDOUT: %.loc14_56: %tuple.type.e89 = tuple_literal (%.loc14_44, %.loc14_55)
  60. // CHECK:STDOUT: assign file.%x.var, <error>
  61. // CHECK:STDOUT: return
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: