fail_out_of_bound.carbon 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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: %Int32: type = fn_type @Int32 [template]
  14. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  15. // CHECK:STDOUT: %struct: Int32 = struct_value () [template]
  16. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  17. // CHECK:STDOUT: %.3: type = array_type %.2, i32 [template]
  18. // CHECK:STDOUT: %.4: type = ptr_type [i32; 1] [template]
  19. // CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
  20. // CHECK:STDOUT: %.6: i32 = int_literal 3 [template]
  21. // CHECK:STDOUT: %.7: type = tuple_type (i32, i32, i32) [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: file {
  25. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  26. // CHECK:STDOUT: .Core = %Core
  27. // CHECK:STDOUT: .a = %a
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  30. // CHECK:STDOUT: %import_ref: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct]
  31. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct() [template = i32]
  32. // CHECK:STDOUT: %.loc10_14: i32 = int_literal 1 [template = constants.%.2]
  33. // CHECK:STDOUT: %.loc10_9.1: type = value_of_initializer %int.make_type_32 [template = i32]
  34. // CHECK:STDOUT: %.loc10_9.2: type = converted %int.make_type_32, %.loc10_9.1 [template = i32]
  35. // CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, i32 [template = constants.%.3]
  36. // CHECK:STDOUT: %a.var: ref [i32; 1] = var a
  37. // CHECK:STDOUT: %a: ref [i32; 1] = bind_name a, %a.var
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @__global_init() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %.loc10_20: i32 = int_literal 1 [template = constants.%.2]
  45. // CHECK:STDOUT: %.loc10_23: i32 = int_literal 2 [template = constants.%.5]
  46. // CHECK:STDOUT: %.loc10_26: i32 = int_literal 3 [template = constants.%.6]
  47. // CHECK:STDOUT: %.loc10_27: (i32, i32, i32) = tuple_literal (%.loc10_20, %.loc10_23, %.loc10_26)
  48. // CHECK:STDOUT: assign file.%a.var, <error>
  49. // CHECK:STDOUT: return
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: