fail_call_invalid.carbon 3.7 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. interface Simple {
  7. fn G[self: Self]();
  8. }
  9. impl i32 as Simple {
  10. // CHECK:STDERR: fail_call_invalid.carbon:[[@LINE+3]]:14: ERROR: Name `Undeclared` not found.
  11. // CHECK:STDERR: fn G[self: Undeclared]();
  12. // CHECK:STDERR: ^~~~~~~~~~
  13. fn G[self: Undeclared]();
  14. }
  15. fn InstanceCall(n: i32) {
  16. n.(Simple.G)();
  17. }
  18. // CHECK:STDOUT: --- fail_call_invalid.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %.1: type = interface_type @Simple [template]
  22. // CHECK:STDOUT: %.2: type = assoc_entity_type @Simple, <function> [template]
  23. // CHECK:STDOUT: %.3: <associated <function> in Simple> = assoc_entity element0, @Simple.%G [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Simple = %Simple.decl
  29. // CHECK:STDOUT: .InstanceCall = %InstanceCall
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {}
  32. // CHECK:STDOUT: impl_decl @impl {
  33. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, %Simple.decl [template = constants.%.1]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %InstanceCall: <function> = fn_decl @InstanceCall [template] {
  36. // CHECK:STDOUT: %n.loc18_17.1: i32 = param n
  37. // CHECK:STDOUT: @InstanceCall.%n: i32 = bind_name n, %n.loc18_17.1
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: interface @Simple {
  42. // CHECK:STDOUT: %Self: Simple = bind_symbolic_name Self [symbolic]
  43. // CHECK:STDOUT: %G: <function> = fn_decl @G.1 [template] {
  44. // CHECK:STDOUT: %Self.ref: Simple = name_ref Self, %Self [symbolic = %Self]
  45. // CHECK:STDOUT: %.loc8_14.1: type = facet_type_access %Self.ref [symbolic = %Self]
  46. // CHECK:STDOUT: %.loc8_14.2: type = converted %Self.ref, %.loc8_14.1 [symbolic = %Self]
  47. // CHECK:STDOUT: %self.loc8_8.1: Self = param self
  48. // CHECK:STDOUT: %self.loc8_8.2: Self = bind_name self, %self.loc8_8.1
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %.loc8_21: <associated <function> in Simple> = assoc_entity element0, %G [template = constants.%.3]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !members:
  53. // CHECK:STDOUT: .Self = %Self
  54. // CHECK:STDOUT: .G = %.loc8_21
  55. // CHECK:STDOUT: witness = (%G)
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: impl @impl: i32 as Simple {
  59. // CHECK:STDOUT: %G: <function> = fn_decl @G.2 [template] {
  60. // CHECK:STDOUT: %Undeclared.ref: <error> = name_ref Undeclared, <error> [template = <error>]
  61. // CHECK:STDOUT: %self.loc15_8.1: <error> = param self
  62. // CHECK:STDOUT: %self.loc15_8.2: <error> = bind_name self, %self.loc15_8.1
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %.1: <witness> = interface_witness (<error>) [template = <error>]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .G = %G
  68. // CHECK:STDOUT: witness = %.1
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @G.1[@Simple.%self.loc8_8.2: Self]();
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: fn @G.2[@impl.%self.loc15_8.2: <error>]();
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: fn @InstanceCall(%n: i32) {
  76. // CHECK:STDOUT: !entry:
  77. // CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
  78. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [template = constants.%.1]
  79. // CHECK:STDOUT: %G.ref: <associated <function> in Simple> = name_ref G, @Simple.%.loc8_21 [template = constants.%.3]
  80. // CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = <error>]
  81. // CHECK:STDOUT: return
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: