fail_non_tuple_access.carbon 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/index/fail_non_tuple_access.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_non_tuple_access.carbon
  14. fn Main() {
  15. // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `Core.IntLiteral` that does not implement that interface [MissingImplInMemberAccess]
  16. // CHECK:STDERR: 0[1];
  17. // CHECK:STDERR: ^~~~
  18. // CHECK:STDERR:
  19. 0[1];
  20. }
  21. // CHECK:STDOUT: --- fail_non_tuple_access.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  25. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  26. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  27. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  28. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  29. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  34. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .Main = %Main.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn @Main() {
  51. // CHECK:STDOUT: !entry:
  52. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  53. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: