fail_member_of_let.carbon 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 {
  7. fn F() -> i32;
  8. }
  9. // TODO: Use `:!` here once it is available.
  10. let T: type = Class;
  11. // The class name is required to be written in the same way as in the class
  12. // declaration. An expression that evaluates to the class name is not accepted.
  13. // CHECK:STDERR: fail_member_of_let.carbon:[[@LINE+3]]:4: ERROR: Name `T` not found.
  14. // CHECK:STDERR: fn T.F() {}
  15. // CHECK:STDERR: ^
  16. fn T.F() {}
  17. // CHECK:STDOUT: --- fail_member_of_let.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  21. // CHECK:STDOUT: %F: type = fn_type @F [template]
  22. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  23. // CHECK:STDOUT: %struct.1: F = struct_value () [template]
  24. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  25. // CHECK:STDOUT: %.3: type = fn_type @.1 [template]
  26. // CHECK:STDOUT: %struct.2: <invalid> = struct_value () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .Class = %Class.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  36. // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class]
  37. // CHECK:STDOUT: %T: type = bind_name T, %Class.ref
  38. // CHECK:STDOUT: %.decl: <invalid> = fn_decl @.1 [template = constants.%struct.2] {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: class @Class {
  42. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.1] {
  43. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: !members:
  47. // CHECK:STDOUT: .Self = constants.%Class
  48. // CHECK:STDOUT: .F = %F.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: fn @F() -> i32;
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @.1() {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: return
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: