fail_array_out_of_bound_access.carbon 1.2 KB

12345678910111213141516171819202122232425262728
  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. var a: [i32; 1] = (12,);
  7. // CHECK:STDERR: fail_array_out_of_bound_access.carbon:[[@LINE+3]]:17: Index `2` is past the end of `[i32; 1]`.
  8. // CHECK:STDERR: var b: i32 = a[2];
  9. // CHECK:STDERR: ^
  10. var b: i32 = a[2];
  11. // CHECK:STDOUT: package {
  12. // CHECK:STDOUT: %.loc7_14: i32 = int_literal 1
  13. // CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32
  14. // CHECK:STDOUT: %a: ref [i32; 1] = var "a"
  15. // CHECK:STDOUT: %.loc7_20.1: i32 = int_literal 12
  16. // CHECK:STDOUT: %.loc7_20.2: i32 = stub_reference %.loc7_20.1
  17. // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32)
  18. // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_literal (%.loc7_20.2)
  19. // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2
  20. // CHECK:STDOUT: assign %a, %.loc7_23.3
  21. // CHECK:STDOUT: %b: ref i32 = var "b"
  22. // CHECK:STDOUT: %.loc11_16: i32 = int_literal 2
  23. // CHECK:STDOUT: %.loc11_17.1: ref i32 = array_index %a, <error>
  24. // CHECK:STDOUT: %.loc11_17.2: i32 = bind_value %.loc11_17.1
  25. // CHECK:STDOUT: assign %b, %.loc11_17.2
  26. // CHECK:STDOUT: }