fail_too_few_element.carbon 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/tuples/fail_too_few_element.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuples/fail_too_few_element.carbon
  10. // CHECK:STDERR: fail_too_few_element.carbon:[[@LINE+3]]:21: ERROR: Cannot initialize tuple of 2 element(s) from tuple with 1 element(s).
  11. // CHECK:STDERR: var x: (i32, i32) = (2, );
  12. // CHECK:STDERR: ^~~~~
  13. var x: (i32, i32) = (2, );
  14. // CHECK:STDOUT: --- fail_too_few_element.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  18. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  19. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  20. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  21. // CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template]
  22. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  23. // CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
  24. // CHECK:STDOUT: %.6: type = tuple_type (i32) [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Core = %Core
  30. // CHECK:STDOUT: .x = %x
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  33. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  34. // CHECK:STDOUT: %int.make_type_32.loc14_9: init type = call constants.%Int32() [template = i32]
  35. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  36. // CHECK:STDOUT: %int.make_type_32.loc14_14: init type = call constants.%Int32() [template = i32]
  37. // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%int.make_type_32.loc14_9, %int.make_type_32.loc14_14)
  38. // CHECK:STDOUT: %.loc14_17.2: type = value_of_initializer %int.make_type_32.loc14_9 [template = i32]
  39. // CHECK:STDOUT: %.loc14_17.3: type = converted %int.make_type_32.loc14_9, %.loc14_17.2 [template = i32]
  40. // CHECK:STDOUT: %.loc14_17.4: type = value_of_initializer %int.make_type_32.loc14_14 [template = i32]
  41. // CHECK:STDOUT: %.loc14_17.5: type = converted %int.make_type_32.loc14_14, %.loc14_17.4 [template = i32]
  42. // CHECK:STDOUT: %.loc14_17.6: type = converted %.loc14_17.1, constants.%.3 [template = constants.%.3]
  43. // CHECK:STDOUT: %x.var: ref %.3 = var x
  44. // CHECK:STDOUT: %x: ref %.3 = bind_name x, %x.var
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @__global_init() {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: %.loc14_22: i32 = int_literal 2 [template = constants.%.5]
  52. // CHECK:STDOUT: %.loc14_25: %.6 = tuple_literal (%.loc14_22)
  53. // CHECK:STDOUT: assign file.%x.var, <error>
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: