fail_unknown_member.carbon 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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: .Class = %Class.decl
  28. // CHECK:STDOUT: .G = %G
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  31. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
  32. // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class]
  33. // CHECK:STDOUT: %c.loc11_6.1: Class = param c
  34. // CHECK:STDOUT: @G.%c: Class = bind_name c, %c.loc11_6.1
  35. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: class @Class {
  40. // CHECK:STDOUT: %.loc8: <unbound element of class Class> = field_decl n, element0 [template]
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: !members:
  43. // CHECK:STDOUT: .Self = constants.%Class
  44. // CHECK:STDOUT: .n = %.loc8
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @G(%c: Class) -> i32 {
  48. // CHECK:STDOUT: !entry:
  49. // CHECK:STDOUT: %c.ref: Class = name_ref c, %c
  50. // CHECK:STDOUT: %something.ref: <error> = name_ref something, <error> [template = <error>]
  51. // CHECK:STDOUT: return <error>
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: