fail_member_lookup.carbon 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/interface/no_prelude/fail_member_lookup.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon
  10. interface Interface {
  11. fn F();
  12. let T:! type;
  13. }
  14. fn F() {
  15. // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: error: value of type `<associated <type of F> in Interface>` is not callable [CallToNonCallable]
  16. // CHECK:STDERR: Interface.F();
  17. // CHECK:STDERR: ^~~~~~~~~~~~
  18. // CHECK:STDERR:
  19. Interface.F();
  20. // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+3]]:10: error: package `Core` implicitly referenced here, but not found [CoreNotFound]
  21. // CHECK:STDERR: var v: Interface.T;
  22. // CHECK:STDERR: ^~~~~~~~~~~
  23. var v: Interface.T;
  24. }
  25. // CHECK:STDOUT: --- fail_member_lookup.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %Interface.type: type = interface_type @Interface [template]
  29. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic]
  30. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  31. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  32. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  33. // CHECK:STDOUT: %.2: type = assoc_entity_type %Interface.type, %F.type.1 [template]
  34. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @Interface.%F.decl [template]
  35. // CHECK:STDOUT: %.4: type = assoc_entity_type %Interface.type, type [template]
  36. // CHECK:STDOUT: %.5: %.4 = assoc_entity element1, @Interface.%T [template]
  37. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  38. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Interface = %Interface.decl
  44. // CHECK:STDOUT: .F = %F.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%Interface.type] {} {}
  47. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: interface @Interface {
  51. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  52. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  53. // CHECK:STDOUT: %.loc12: %.2 = assoc_entity element0, %F.decl [template = constants.%.3]
  54. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  55. // CHECK:STDOUT: %.loc14: %.4 = assoc_entity element1, %T [template = constants.%.5]
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !members:
  58. // CHECK:STDOUT: .Self = %Self
  59. // CHECK:STDOUT: .F = %.loc12
  60. // CHECK:STDOUT: .T = %.loc14
  61. // CHECK:STDOUT: witness = (%F.decl, %T)
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: generic fn @F.1(@Interface.%Self: %Interface.type) {
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: fn();
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @F.2() {
  70. // CHECK:STDOUT: !entry:
  71. // CHECK:STDOUT: %Interface.ref.loc22: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  72. // CHECK:STDOUT: %F.ref: %.2 = name_ref F, @Interface.%.loc12 [template = constants.%.3]
  73. // CHECK:STDOUT: %Interface.ref.loc27: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  74. // CHECK:STDOUT: %T.ref: %.4 = name_ref T, @Interface.%.loc14 [template = constants.%.5]
  75. // CHECK:STDOUT: %.loc27: type = converted %T.ref, <error> [template = <error>]
  76. // CHECK:STDOUT: %v.var: ref <error> = var v
  77. // CHECK:STDOUT: %v: ref <error> = bind_name v, %v.var
  78. // CHECK:STDOUT: return
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  82. // CHECK:STDOUT: