nested_tuple.carbon 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/nested_tuple.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/nested_tuple.carbon
  10. var x: ((i32, i32), i32) = ((12, 76), 6);
  11. // CHECK:STDOUT: --- nested_tuple.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  15. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  16. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  17. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  18. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
  19. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%tuple.type.1, type) [template]
  20. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (%i32, %i32) [template]
  21. // CHECK:STDOUT: %tuple.type.4: type = tuple_type (%tuple.type.3, %i32) [template]
  22. // CHECK:STDOUT: %.4: Core.IntLiteral = int_value 12 [template]
  23. // CHECK:STDOUT: %.5: Core.IntLiteral = int_value 76 [template]
  24. // CHECK:STDOUT: %tuple.type.6: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
  25. // CHECK:STDOUT: %.6: Core.IntLiteral = int_value 6 [template]
  26. // CHECK:STDOUT: %tuple.type.7: type = tuple_type (%tuple.type.6, Core.IntLiteral) [template]
  27. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  28. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  29. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  30. // CHECK:STDOUT: %.26: <witness> = interface_witness (%Convert.14) [template]
  31. // CHECK:STDOUT: %.27: <bound method> = bound_method %.4, %Convert.14 [template]
  32. // CHECK:STDOUT: %.28: <specific function> = specific_function %.27, @Convert.2(%.1) [template]
  33. // CHECK:STDOUT: %.29: %i32 = int_value 12 [template]
  34. // CHECK:STDOUT: %.30: <bound method> = bound_method %.5, %Convert.14 [template]
  35. // CHECK:STDOUT: %.31: <specific function> = specific_function %.30, @Convert.2(%.1) [template]
  36. // CHECK:STDOUT: %.32: %i32 = int_value 76 [template]
  37. // CHECK:STDOUT: %tuple.1: %tuple.type.3 = tuple_value (%.29, %.32) [template]
  38. // CHECK:STDOUT: %.33: <bound method> = bound_method %.6, %Convert.14 [template]
  39. // CHECK:STDOUT: %.34: <specific function> = specific_function %.33, @Convert.2(%.1) [template]
  40. // CHECK:STDOUT: %.35: %i32 = int_value 6 [template]
  41. // CHECK:STDOUT: %tuple.2: %tuple.type.4 = tuple_value (%tuple.1, %.35) [template]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: imports {
  45. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  46. // CHECK:STDOUT: .Int = %import_ref.1
  47. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  48. // CHECK:STDOUT: import Core//prelude
  49. // CHECK:STDOUT: import Core//prelude/...
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: file {
  54. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  55. // CHECK:STDOUT: .Core = imports.%Core
  56. // CHECK:STDOUT: .x = %x
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %Core.import = import Core
  59. // CHECK:STDOUT: %.loc11_10: Core.IntLiteral = int_value 32 [template = constants.%.1]
  60. // CHECK:STDOUT: %int.make_type_signed.loc11_10: init type = call constants.%Int(%.loc11_10) [template = constants.%i32]
  61. // CHECK:STDOUT: %.loc11_15: Core.IntLiteral = int_value 32 [template = constants.%.1]
  62. // CHECK:STDOUT: %int.make_type_signed.loc11_15: init type = call constants.%Int(%.loc11_15) [template = constants.%i32]
  63. // CHECK:STDOUT: %.loc11_18: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc11_10, %int.make_type_signed.loc11_15)
  64. // CHECK:STDOUT: %.loc11_21: Core.IntLiteral = int_value 32 [template = constants.%.1]
  65. // CHECK:STDOUT: %int.make_type_signed.loc11_21: init type = call constants.%Int(%.loc11_21) [template = constants.%i32]
  66. // CHECK:STDOUT: %.loc11_24.1: %tuple.type.2 = tuple_literal (%.loc11_18, %int.make_type_signed.loc11_21)
  67. // CHECK:STDOUT: %.loc11_24.2: type = value_of_initializer %int.make_type_signed.loc11_10 [template = constants.%i32]
  68. // CHECK:STDOUT: %.loc11_24.3: type = converted %int.make_type_signed.loc11_10, %.loc11_24.2 [template = constants.%i32]
  69. // CHECK:STDOUT: %.loc11_24.4: type = value_of_initializer %int.make_type_signed.loc11_15 [template = constants.%i32]
  70. // CHECK:STDOUT: %.loc11_24.5: type = converted %int.make_type_signed.loc11_15, %.loc11_24.4 [template = constants.%i32]
  71. // CHECK:STDOUT: %.loc11_24.6: type = converted %.loc11_18, constants.%tuple.type.3 [template = constants.%tuple.type.3]
  72. // CHECK:STDOUT: %.loc11_24.7: type = value_of_initializer %int.make_type_signed.loc11_21 [template = constants.%i32]
  73. // CHECK:STDOUT: %.loc11_24.8: type = converted %int.make_type_signed.loc11_21, %.loc11_24.7 [template = constants.%i32]
  74. // CHECK:STDOUT: %.loc11_24.9: type = converted %.loc11_24.1, constants.%tuple.type.4 [template = constants.%tuple.type.4]
  75. // CHECK:STDOUT: %x.var: ref %tuple.type.4 = var x
  76. // CHECK:STDOUT: %x: ref %tuple.type.4 = bind_name x, %x.var
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @__global_init() {
  80. // CHECK:STDOUT: !entry:
  81. // CHECK:STDOUT: %.loc11_30: Core.IntLiteral = int_value 12 [template = constants.%.4]
  82. // CHECK:STDOUT: %.loc11_34: Core.IntLiteral = int_value 76 [template = constants.%.5]
  83. // CHECK:STDOUT: %.loc11_36.1: %tuple.type.6 = tuple_literal (%.loc11_30, %.loc11_34)
  84. // CHECK:STDOUT: %.loc11_39: Core.IntLiteral = int_value 6 [template = constants.%.6]
  85. // CHECK:STDOUT: %.loc11_40.1: %tuple.type.7 = tuple_literal (%.loc11_36.1, %.loc11_39)
  86. // CHECK:STDOUT: %.loc11_36.2: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  87. // CHECK:STDOUT: %.loc11_36.3: <bound method> = bound_method %.loc11_30, %.loc11_36.2 [template = constants.%.27]
  88. // CHECK:STDOUT: %.loc11_36.4: <specific function> = specific_function %.loc11_36.3, @Convert.2(constants.%.1) [template = constants.%.28]
  89. // CHECK:STDOUT: %int.convert_checked.loc11_36.1: init %i32 = call %.loc11_36.4(%.loc11_30) [template = constants.%.29]
  90. // CHECK:STDOUT: %.loc11_36.5: init %i32 = converted %.loc11_30, %int.convert_checked.loc11_36.1 [template = constants.%.29]
  91. // CHECK:STDOUT: %.loc11_40.2: ref %tuple.type.3 = tuple_access file.%x.var, element0
  92. // CHECK:STDOUT: %.loc11_36.6: ref %i32 = tuple_access %.loc11_40.2, element0
  93. // CHECK:STDOUT: %.loc11_36.7: init %i32 = initialize_from %.loc11_36.5 to %.loc11_36.6 [template = constants.%.29]
  94. // CHECK:STDOUT: %.loc11_36.8: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  95. // CHECK:STDOUT: %.loc11_36.9: <bound method> = bound_method %.loc11_34, %.loc11_36.8 [template = constants.%.30]
  96. // CHECK:STDOUT: %.loc11_36.10: <specific function> = specific_function %.loc11_36.9, @Convert.2(constants.%.1) [template = constants.%.31]
  97. // CHECK:STDOUT: %int.convert_checked.loc11_36.2: init %i32 = call %.loc11_36.10(%.loc11_34) [template = constants.%.32]
  98. // CHECK:STDOUT: %.loc11_36.11: init %i32 = converted %.loc11_34, %int.convert_checked.loc11_36.2 [template = constants.%.32]
  99. // CHECK:STDOUT: %.loc11_36.12: ref %i32 = tuple_access %.loc11_40.2, element1
  100. // CHECK:STDOUT: %.loc11_36.13: init %i32 = initialize_from %.loc11_36.11 to %.loc11_36.12 [template = constants.%.32]
  101. // CHECK:STDOUT: %.loc11_36.14: init %tuple.type.3 = tuple_init (%.loc11_36.7, %.loc11_36.13) to %.loc11_40.2 [template = constants.%tuple.1]
  102. // CHECK:STDOUT: %.loc11_40.3: init %tuple.type.3 = converted %.loc11_36.1, %.loc11_36.14 [template = constants.%tuple.1]
  103. // CHECK:STDOUT: %.loc11_40.4: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  104. // CHECK:STDOUT: %.loc11_40.5: <bound method> = bound_method %.loc11_39, %.loc11_40.4 [template = constants.%.33]
  105. // CHECK:STDOUT: %.loc11_40.6: <specific function> = specific_function %.loc11_40.5, @Convert.2(constants.%.1) [template = constants.%.34]
  106. // CHECK:STDOUT: %int.convert_checked.loc11_40: init %i32 = call %.loc11_40.6(%.loc11_39) [template = constants.%.35]
  107. // CHECK:STDOUT: %.loc11_40.7: init %i32 = converted %.loc11_39, %int.convert_checked.loc11_40 [template = constants.%.35]
  108. // CHECK:STDOUT: %.loc11_40.8: ref %i32 = tuple_access file.%x.var, element1
  109. // CHECK:STDOUT: %.loc11_40.9: init %i32 = initialize_from %.loc11_40.7 to %.loc11_40.8 [template = constants.%.35]
  110. // CHECK:STDOUT: %.loc11_40.10: init %tuple.type.4 = tuple_init (%.loc11_40.3, %.loc11_40.9) to file.%x.var [template = constants.%tuple.2]
  111. // CHECK:STDOUT: %.loc11_41: init %tuple.type.4 = converted %.loc11_40.1, %.loc11_40.10 [template = constants.%tuple.2]
  112. // CHECK:STDOUT: assign file.%x.var, %.loc11_41
  113. // CHECK:STDOUT: return
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: