fail_too_few_element.carbon 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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+3]]: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. var x: (i32, i32) = (2, );
  14. // CHECK:STDOUT: --- fail_too_few_element.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  18. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  19. // CHECK:STDOUT: %tuple.type.471: type = tuple_type (%i32, %i32) [template]
  20. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  21. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: imports {
  25. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  26. // CHECK:STDOUT: .Int = %import_ref.187
  27. // CHECK:STDOUT: import Core//prelude
  28. // CHECK:STDOUT: import Core//prelude/...
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .Core = imports.%Core
  35. // CHECK:STDOUT: .x = %x
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %Core.import = import Core
  38. // CHECK:STDOUT: %x.var: ref %tuple.type.471 = var x
  39. // CHECK:STDOUT: %x: ref %tuple.type.471 = bind_name x, %x.var
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @__global_init() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  45. // CHECK:STDOUT: %.loc14: %tuple.type.985 = tuple_literal (%int_2)
  46. // CHECK:STDOUT: assign file.%x.var, <error>
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: