fail_unknown_member.carbon 2.4 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. 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: %G: type = fn_type @G [template]
  23. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  24. // CHECK:STDOUT: %struct: G = struct_value () [template]
  25. // CHECK:STDOUT: %.4: type = ptr_type {.n: i32} [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = %Core
  31. // CHECK:STDOUT: .Class = %Class.decl
  32. // CHECK:STDOUT: .G = %G.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: %G.decl: G = fn_decl @G [template = constants.%struct] {
  37. // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class]
  38. // CHECK:STDOUT: %c.loc11_6.1: Class = param c
  39. // CHECK:STDOUT: @G.%c: Class = bind_name c, %c.loc11_6.1
  40. // CHECK:STDOUT: @G.%return: ref i32 = var <return slot>
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: class @Class {
  45. // CHECK:STDOUT: %.loc8: <unbound element of class Class> = field_decl n, element0 [template]
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !members:
  48. // CHECK:STDOUT: .Self = constants.%Class
  49. // CHECK:STDOUT: .n = %.loc8
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @G(%c: Class) -> i32 {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %c.ref: Class = name_ref c, %c
  55. // CHECK:STDOUT: %something.ref: <error> = name_ref something, <error> [template = <error>]
  56. // CHECK:STDOUT: return <error>
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: