fail_non_tuple_access.carbon 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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+4]]:3: error: type `Core.IntLiteral` does not support indexing [TypeNotIndexable]
  12. // CHECK:STDERR: 0[1];
  13. // CHECK:STDERR: ^~~~
  14. // CHECK:STDERR:
  15. 0[1];
  16. }
  17. // CHECK:STDOUT: --- fail_non_tuple_access.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  21. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  22. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  23. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 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: .IndexWith = %Core.IndexWith
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .Main = %Main.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @Main() {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  46. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: