fail_unknown_member.carbon 2.2 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. // AUTOUPDATE
  6. class Class {
  7. var n: i32;
  8. }
  9. fn G(c: Class) -> i32 {
  10. // TODO: Mention the scope in which we looked for the name.
  11. // CHECK:STDERR: fail_unknown_member.carbon:[[@LINE+3]]:10: ERROR: Name `something` not found.
  12. // CHECK:STDERR: return c.something;
  13. // CHECK:STDERR: ^~~~~~~~~~~
  14. return c.something;
  15. }
  16. // CHECK:STDOUT: --- fail_unknown_member.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  20. // CHECK:STDOUT: %.1: type = unbound_element_type Class, i32 [template]
  21. // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template]
  22. // CHECK:STDOUT: %.3: type = ptr_type {.n: i32} [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .Core = %Core
  28. // CHECK:STDOUT: .Class = %Class.decl
  29. // CHECK:STDOUT: .G = %G
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  33. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
  34. // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class]
  35. // CHECK:STDOUT: %c.loc11_6.1: Class = param c
  36. // CHECK:STDOUT: @G.%c: Class = bind_name c, %c.loc11_6.1
  37. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: class @Class {
  42. // CHECK:STDOUT: %.loc8: <unbound element of class Class> = field_decl n, element0 [template]
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: !members:
  45. // CHECK:STDOUT: .Self = constants.%Class
  46. // CHECK:STDOUT: .n = %.loc8
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @G(%c: Class) -> i32 {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: %c.ref: Class = name_ref c, %c
  52. // CHECK:STDOUT: %something.ref: <error> = name_ref something, <error> [template = <error>]
  53. // CHECK:STDOUT: return <error>
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: