fail_empty_tuple_access.carbon 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. fn F() {}
  7. fn Run() {
  8. // CHECK:STDERR: fail_empty_tuple_access.carbon:[[@LINE+3]]:3: ERROR: Tuple element index `0` is past the end of type `()`.
  9. // CHECK:STDERR: F()[0];
  10. // CHECK:STDERR: ^~~~~~
  11. F()[0];
  12. }
  13. // CHECK:STDOUT: --- fail_empty_tuple_access.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  17. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  18. // CHECK:STDOUT: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: file {
  21. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  22. // CHECK:STDOUT: .Core = %Core
  23. // CHECK:STDOUT: .F = %F
  24. // CHECK:STDOUT: .Run = %Run
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  27. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {}
  28. // CHECK:STDOUT: %Run: <function> = fn_decl @Run [template] {}
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: fn @F() {
  32. // CHECK:STDOUT: !entry:
  33. // CHECK:STDOUT: return
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: fn @Run() {
  37. // CHECK:STDOUT: !entry:
  38. // CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%F [template = file.%F]
  39. // CHECK:STDOUT: %F.call: init () = call %F.ref()
  40. // CHECK:STDOUT: %.loc13_7: i32 = int_literal 0 [template = constants.%.2]
  41. // CHECK:STDOUT: %.loc13_4.1: ref () = temporary_storage
  42. // CHECK:STDOUT: %.loc13_4.2: ref () = temporary %.loc13_4.1, %F.call
  43. // CHECK:STDOUT: %.loc13_8: ref <error> = tuple_index %.loc13_4.2, <error>
  44. // CHECK:STDOUT: return
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: