fail_too_few_element.carbon 3.3 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_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/tuple/fail_too_few_element.carbon
  10. // CHECK:STDERR: fail_too_few_element.carbon:[[@LINE+4]]:21: error: cannot initialize tuple of 2 elements from tuple with 1 element [TupleInitElementCountMismatch]
  11. // CHECK:STDERR: var x: (i32, i32) = (2, );
  12. // CHECK:STDERR: ^~~~~
  13. // CHECK:STDERR:
  14. var x: (i32, i32) = (2, );
  15. // CHECK:STDOUT: --- fail_too_few_element.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.d07: type = tuple_type (%i32, %i32) [concrete]
  22. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
  23. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [concrete]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  28. // CHECK:STDOUT: .Int = %Core.Int
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .x = %x
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: name_binding_decl {
  41. // CHECK:STDOUT: %x.patt: %tuple.type.d07 = binding_pattern x
  42. // CHECK:STDOUT: %.loc15_1: %tuple.type.d07 = var_pattern %x.patt
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %x.var: ref %tuple.type.d07 = var x
  45. // CHECK:STDOUT: %.loc15_17.1: type = splice_block %.loc15_17.3 [concrete = constants.%tuple.type.d07] {
  46. // CHECK:STDOUT: %int_32.loc15_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  47. // CHECK:STDOUT: %i32.loc15_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  48. // CHECK:STDOUT: %int_32.loc15_14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  49. // CHECK:STDOUT: %i32.loc15_14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  50. // CHECK:STDOUT: %.loc15_17.2: %tuple.type.24b = tuple_literal (%i32.loc15_9, %i32.loc15_14)
  51. // CHECK:STDOUT: %.loc15_17.3: type = converted %.loc15_17.2, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %x: ref %tuple.type.d07 = bind_name x, %x.var
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @__global_init() {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
  59. // CHECK:STDOUT: %.loc15: %tuple.type.985 = tuple_literal (%int_2)
  60. // CHECK:STDOUT: assign file.%x.var, <error>
  61. // CHECK:STDOUT: return
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: