fail_out_of_bound.carbon 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+3]]:19: ERROR: Cannot initialize array of 1 element(s) from 3 initializer(s).
  7. // CHECK:STDERR: var a: [i32; 1] = (1, 2, 3);
  8. // CHECK:STDERR: ^~~~~~~~~
  9. var a: [i32; 1] = (1, 2, 3);
  10. // CHECK:STDOUT: --- fail_out_of_bound.carbon
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: constants {
  13. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  14. // CHECK:STDOUT: %.2: type = array_type %.1, i32 [template]
  15. // CHECK:STDOUT: %.3: type = ptr_type [i32; 1] [template]
  16. // CHECK:STDOUT: %.4: i32 = int_literal 2 [template]
  17. // CHECK:STDOUT: %.5: i32 = int_literal 3 [template]
  18. // CHECK:STDOUT: %.6: type = tuple_type (i32, i32, i32) [template]
  19. // CHECK:STDOUT: }
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: file {
  22. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  23. // CHECK:STDOUT: .a = %a
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT: %.loc10_14: i32 = int_literal 1 [template = constants.%.1]
  26. // CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, i32 [template = constants.%.2]
  27. // CHECK:STDOUT: %a.var: ref [i32; 1] = var a
  28. // CHECK:STDOUT: %a: ref [i32; 1] = bind_name a, %a.var
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: fn @__global_init() {
  32. // CHECK:STDOUT: !entry:
  33. // CHECK:STDOUT: %.loc10_20: i32 = int_literal 1 [template = constants.%.1]
  34. // CHECK:STDOUT: %.loc10_23: i32 = int_literal 2 [template = constants.%.4]
  35. // CHECK:STDOUT: %.loc10_26: i32 = int_literal 3 [template = constants.%.5]
  36. // CHECK:STDOUT: %.loc10_27: (i32, i32, i32) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_26)
  37. // CHECK:STDOUT: assign file.%a.var, <error>
  38. // CHECK:STDOUT: return
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: