fail_unknown_member.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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_unknown_member.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_unknown_member.carbon
  10. class Class {
  11. var n: i32;
  12. }
  13. fn G(c: Class) -> i32 {
  14. // TODO: Mention the scope in which we looked for the name.
  15. // CHECK:STDERR: fail_unknown_member.carbon:[[@LINE+3]]:10: ERROR: Name `something` not found.
  16. // CHECK:STDERR: return c.something;
  17. // CHECK:STDERR: ^~~~~~~~~~~
  18. return c.something;
  19. }
  20. // CHECK:STDOUT: --- fail_unknown_member.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  24. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  25. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  26. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  27. // CHECK:STDOUT: %.2: type = unbound_element_type %Class, i32 [template]
  28. // CHECK:STDOUT: %.3: type = struct_type {.n: i32} [template]
  29. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  30. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  31. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = %Core
  37. // CHECK:STDOUT: .Class = %Class.decl
  38. // CHECK:STDOUT: .G = %G.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  41. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  42. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  43. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  44. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  45. // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class]
  46. // CHECK:STDOUT: %c.loc15_6.1: %Class = param c
  47. // CHECK:STDOUT: @G.%c: %Class = bind_name c, %c.loc15_6.1
  48. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  49. // CHECK:STDOUT: %.loc15_19.1: type = value_of_initializer %int.make_type_32 [template = i32]
  50. // CHECK:STDOUT: %.loc15_19.2: type = converted %int.make_type_32, %.loc15_19.1 [template = i32]
  51. // CHECK:STDOUT: @G.%return: ref i32 = var <return slot>
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: class @Class {
  56. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  57. // CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  58. // CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_32, %.loc12_10.1 [template = i32]
  59. // CHECK:STDOUT: %.loc12_8: %.2 = field_decl n, element0 [template]
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: !members:
  62. // CHECK:STDOUT: .Self = constants.%Class
  63. // CHECK:STDOUT: .n = %.loc12_8
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @G(%c: %Class) -> i32 {
  69. // CHECK:STDOUT: !entry:
  70. // CHECK:STDOUT: %c.ref: %Class = name_ref c, %c
  71. // CHECK:STDOUT: %something.ref: <error> = name_ref something, <error> [template = <error>]
  72. // CHECK:STDOUT: return <error>
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: