fail_non_tuple_access.carbon 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/index/fail_non_tuple_access.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_non_tuple_access.carbon
  10. fn Main() {
  11. // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+3]]:3: error: type `i32` does not support indexing
  12. // CHECK:STDERR: 0[1];
  13. // CHECK:STDERR: ^~~~
  14. 0[1];
  15. }
  16. // CHECK:STDOUT: --- fail_non_tuple_access.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  22. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  23. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  28. // CHECK:STDOUT: import Core//prelude
  29. // CHECK:STDOUT: import Core//prelude/operators
  30. // CHECK:STDOUT: import Core//prelude/types
  31. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  32. // CHECK:STDOUT: import Core//prelude/operators/as
  33. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  34. // CHECK:STDOUT: import Core//prelude/operators/comparison
  35. // CHECK:STDOUT: import Core//prelude/types/bool
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .Main = %Main.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @Main() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %.loc15_3: i32 = int_literal 0 [template = constants.%.2]
  51. // CHECK:STDOUT: %.loc15_5: i32 = int_literal 1 [template = constants.%.3]
  52. // CHECK:STDOUT: return
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: