fail_todo_generic_method.carbon 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. class Class(T:! type) {
  7. var a: T;
  8. fn F[self: Self](n: T);
  9. }
  10. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope.
  11. // CHECK:STDERR: fn Class(T:! type).F[self: Self](n: T) {}
  12. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE-8]]:1: Name is previously declared here.
  14. // CHECK:STDERR: class Class(T:! type) {
  15. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  16. // CHECK:STDERR:
  17. // CHECK:STDERR: fail_todo_generic_method.carbon:[[@LINE+3]]:19: ERROR: `fn` declarations must either end with a `;` or have a `{ ... }` block for a definition.
  18. // CHECK:STDERR: fn Class(T:! type).F[self: Self](n: T) {}
  19. // CHECK:STDERR: ^
  20. fn Class(T:! type).F[self: Self](n: T) {}
  21. // CHECK:STDOUT: --- fail_todo_generic_method.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  25. // CHECK:STDOUT: %Class.1: type = generic_class_type @Class [template]
  26. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  27. // CHECK:STDOUT: %struct.1: Class = struct_value () [template]
  28. // CHECK:STDOUT: %Class.2: type = class_type @Class [template]
  29. // CHECK:STDOUT: %.2: type = unbound_element_type Class, T [symbolic]
  30. // CHECK:STDOUT: %F: type = fn_type @F [template]
  31. // CHECK:STDOUT: %struct.2: F = struct_value () [template]
  32. // CHECK:STDOUT: %.3: type = struct_type {.a: T} [symbolic]
  33. // CHECK:STDOUT: %.4: type = fn_type @.1 [template]
  34. // CHECK:STDOUT: %struct.3: <invalid> = struct_value () [template]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .Core = %Core
  40. // CHECK:STDOUT: .Class = %Class.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  43. // CHECK:STDOUT: %Class.decl: Class = class_decl @Class [template = constants.%struct.1] {
  44. // CHECK:STDOUT: %T.loc7_13.1: type = param T
  45. // CHECK:STDOUT: %T.loc7_13.2: type = bind_symbolic_name T 0, %T.loc7_13.1 [symbolic = constants.%T]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %.decl: <invalid> = fn_decl @.1 [template = constants.%struct.3] {
  48. // CHECK:STDOUT: %T.loc22_10.1: type = param T
  49. // CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 0, %T.loc22_10.1 [symbolic = constants.%T]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: class @Class {
  54. // CHECK:STDOUT: %T.ref.loc8: type = name_ref T, file.%T.loc7_13.2 [symbolic = constants.%T]
  55. // CHECK:STDOUT: %.loc8: <unbound element of class Class> = field_decl a, element0 [template]
  56. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.2] {
  57. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [template = constants.%Class.2]
  58. // CHECK:STDOUT: %self.loc9_8.1: Class = param self
  59. // CHECK:STDOUT: %self.loc9_8.2: Class = bind_name self, %self.loc9_8.1
  60. // CHECK:STDOUT: %T.ref.loc9: type = name_ref T, file.%T.loc7_13.2 [symbolic = constants.%T]
  61. // CHECK:STDOUT: %n.loc9_20.1: T = param n
  62. // CHECK:STDOUT: %n.loc9_20.2: T = bind_name n, %n.loc9_20.1
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: !members:
  66. // CHECK:STDOUT: .Self = constants.%Class.2
  67. // CHECK:STDOUT: .a = %.loc8
  68. // CHECK:STDOUT: .F = %F.decl
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @F[@Class.%self.loc9_8.2: Class](@Class.%n.loc9_20.2: T);
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: fn @.1(%T: type);
  74. // CHECK:STDOUT: