fail_assign_nested.carbon 5.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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+4]]: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. // CHECK:STDERR:
  14. var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6));
  15. // CHECK:STDOUT: --- fail_assign_nested.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  19. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  20. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  21. // CHECK:STDOUT: %tuple.type.1c9: type = tuple_type (%tuple.type.24b, %tuple.type.24b) [concrete]
  22. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
  23. // CHECK:STDOUT: %tuple.type.ff1: type = tuple_type (%tuple.type.d07, %tuple.type.d07) [concrete]
  24. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  25. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
  26. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
  27. // CHECK:STDOUT: %tuple.type.37f: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
  28. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete]
  29. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete]
  30. // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [concrete]
  31. // CHECK:STDOUT: %tuple.type.e89: type = tuple_type (%tuple.type.37f, %tuple.type.37f) [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  36. // CHECK:STDOUT: .Int = %Core.Int
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .x = %x
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.import = import Core
  48. // CHECK:STDOUT: name_binding_decl {
  49. // CHECK:STDOUT: %x.patt: %tuple.type.ff1 = binding_pattern x
  50. // CHECK:STDOUT: %.loc15_1: %tuple.type.ff1 = var_pattern %x.patt
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %x.var: ref %tuple.type.ff1 = var x
  53. // CHECK:STDOUT: %.loc15_31.1: type = splice_block %.loc15_31.5 [concrete = constants.%tuple.type.ff1] {
  54. // CHECK:STDOUT: %int_32.loc15_10: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  55. // CHECK:STDOUT: %i32.loc15_10: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  56. // CHECK:STDOUT: %int_32.loc15_15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  57. // CHECK:STDOUT: %i32.loc15_15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  58. // CHECK:STDOUT: %.loc15_18: %tuple.type.24b = tuple_literal (%i32.loc15_10, %i32.loc15_15)
  59. // CHECK:STDOUT: %int_32.loc15_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  60. // CHECK:STDOUT: %i32.loc15_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  61. // CHECK:STDOUT: %int_32.loc15_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  62. // CHECK:STDOUT: %i32.loc15_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  63. // CHECK:STDOUT: %.loc15_30: %tuple.type.24b = tuple_literal (%i32.loc15_22, %i32.loc15_27)
  64. // CHECK:STDOUT: %.loc15_31.2: %tuple.type.1c9 = tuple_literal (%.loc15_18, %.loc15_30)
  65. // CHECK:STDOUT: %.loc15_31.3: type = converted %.loc15_18, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  66. // CHECK:STDOUT: %.loc15_31.4: type = converted %.loc15_30, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  67. // CHECK:STDOUT: %.loc15_31.5: type = converted %.loc15_31.2, constants.%tuple.type.ff1 [concrete = constants.%tuple.type.ff1]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %x: ref %tuple.type.ff1 = bind_name x, %x.var
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: fn @__global_init() {
  73. // CHECK:STDOUT: !entry:
  74. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  75. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
  76. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
  77. // CHECK:STDOUT: %.loc15_44: %tuple.type.37f = tuple_literal (%int_1, %int_2, %int_3)
  78. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4]
  79. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5]
  80. // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [concrete = constants.%int_6]
  81. // CHECK:STDOUT: %.loc15_55: %tuple.type.37f = tuple_literal (%int_4, %int_5, %int_6)
  82. // CHECK:STDOUT: %.loc15_56: %tuple.type.e89 = tuple_literal (%.loc15_44, %.loc15_55)
  83. // CHECK:STDOUT: assign file.%x.var, <error>
  84. // CHECK:STDOUT: return
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: