fail_non_tuple_access.carbon 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 `Core.IntLiteral` does not support indexing [TypeNotIndexable]
  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: %Main: %Main.type = struct_value () [template]
  21. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 0 [template]
  22. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 1 [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: imports {
  26. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  27. // CHECK:STDOUT: .IndexWith = %import_ref.1
  28. // CHECK:STDOUT: import Core//prelude
  29. // CHECK:STDOUT: import Core//prelude/...
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .Main = %Main.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.import = import Core
  39. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @Main() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %.loc15_3: Core.IntLiteral = int_value 0 [template = constants.%.1]
  45. // CHECK:STDOUT: %.loc15_5: Core.IntLiteral = int_value 1 [template = constants.%.2]
  46. // CHECK:STDOUT: return
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: