one_element.carbon 6.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/one_element.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/one_element.carbon
  10. var x: (i32,) = (4,);
  11. var y: (i32,) = x;
  12. // CHECK:STDOUT: --- one_element.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  16. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  17. // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [concrete]
  18. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [concrete]
  19. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  20. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [concrete]
  21. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  22. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  23. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [concrete]
  24. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [concrete]
  25. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  26. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [concrete]
  27. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  28. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
  29. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [concrete]
  30. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  31. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_4.940) [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: .ImplicitAs = %Core.ImplicitAs
  38. // CHECK:STDOUT: import Core//prelude
  39. // CHECK:STDOUT: import Core//prelude/...
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .x = %x
  47. // CHECK:STDOUT: .y = %y
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: name_binding_decl {
  51. // CHECK:STDOUT: %x.patt: %tuple.type.a1c = binding_pattern x
  52. // CHECK:STDOUT: %.loc11_1: %tuple.type.a1c = var_pattern %x.patt
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %x.var: ref %tuple.type.a1c = var x
  55. // CHECK:STDOUT: %.loc11_13.1: type = splice_block %.loc11_13.3 [concrete = constants.%tuple.type.a1c] {
  56. // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  57. // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  58. // CHECK:STDOUT: %.loc11_13.2: %tuple.type.85c = tuple_literal (%i32.loc11)
  59. // CHECK:STDOUT: %.loc11_13.3: type = converted %.loc11_13.2, constants.%tuple.type.a1c [concrete = constants.%tuple.type.a1c]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %x: ref %tuple.type.a1c = bind_name x, %x.var
  62. // CHECK:STDOUT: name_binding_decl {
  63. // CHECK:STDOUT: %y.patt: %tuple.type.a1c = binding_pattern y
  64. // CHECK:STDOUT: %.loc12_1: %tuple.type.a1c = var_pattern %y.patt
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %y.var: ref %tuple.type.a1c = var y
  67. // CHECK:STDOUT: %.loc12_13.1: type = splice_block %.loc12_13.3 [concrete = constants.%tuple.type.a1c] {
  68. // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  69. // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  70. // CHECK:STDOUT: %.loc12_13.2: %tuple.type.85c = tuple_literal (%i32.loc12)
  71. // CHECK:STDOUT: %.loc12_13.3: type = converted %.loc12_13.2, constants.%tuple.type.a1c [concrete = constants.%tuple.type.a1c]
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %y: ref %tuple.type.a1c = bind_name y, %y.var
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @__global_init() {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  79. // CHECK:STDOUT: %.loc11_20.1: %tuple.type.985 = tuple_literal (%int_4)
  80. // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  81. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_4, %impl.elem0 [concrete = constants.%Convert.bound]
  82. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  83. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_4) [concrete = constants.%int_4.940]
  84. // CHECK:STDOUT: %.loc11_20.2: init %i32 = converted %int_4, %int.convert_checked [concrete = constants.%int_4.940]
  85. // CHECK:STDOUT: %.loc11_20.3: init %tuple.type.a1c = tuple_init (%.loc11_20.2) to file.%x.var [concrete = constants.%tuple]
  86. // CHECK:STDOUT: %.loc11_1: init %tuple.type.a1c = converted %.loc11_20.1, %.loc11_20.3 [concrete = constants.%tuple]
  87. // CHECK:STDOUT: assign file.%x.var, %.loc11_1
  88. // CHECK:STDOUT: %x.ref: ref %tuple.type.a1c = name_ref x, file.%x
  89. // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %x.ref, element0
  90. // CHECK:STDOUT: %.loc12_17.1: %i32 = bind_value %tuple.elem0
  91. // CHECK:STDOUT: %.loc12_17.2: init %tuple.type.a1c = tuple_init (%.loc12_17.1) to file.%y.var
  92. // CHECK:STDOUT: %.loc12_1: init %tuple.type.a1c = converted %x.ref, %.loc12_17.2
  93. // CHECK:STDOUT: assign file.%y.var, %.loc12_1
  94. // CHECK:STDOUT: return
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: