fail_scope.carbon 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_scope.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_scope.carbon
  10. class Class {
  11. fn F() -> i32 {
  12. return 1;
  13. }
  14. }
  15. fn G() -> i32 {
  16. // CHECK:STDERR: fail_scope.carbon:[[@LINE+3]]:10: ERROR: Name `F` not found.
  17. // CHECK:STDERR: return F();
  18. // CHECK:STDERR: ^
  19. return F();
  20. }
  21. // CHECK:STDOUT: --- fail_scope.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  25. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  26. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  27. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  28. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  29. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  30. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  31. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  32. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  33. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = %Core
  39. // CHECK:STDOUT: .Class = %Class.decl
  40. // CHECK:STDOUT: .G = %G.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  43. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  44. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  45. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  46. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  47. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  48. // CHECK:STDOUT: %.loc17_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  49. // CHECK:STDOUT: %.loc17_11.2: type = converted %int.make_type_32, %.loc17_11.1 [template = i32]
  50. // CHECK:STDOUT: @G.%return: ref i32 = var <return slot>
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: class @Class {
  55. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  56. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  57. // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
  58. // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32, %.loc12_13.1 [template = i32]
  59. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = constants.%Class
  64. // CHECK:STDOUT: .F = %F.decl
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @F() -> i32 {
  70. // CHECK:STDOUT: !entry:
  71. // CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.3]
  72. // CHECK:STDOUT: return %.loc13
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: fn @G() -> i32 {
  76. // CHECK:STDOUT: !entry:
  77. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
  78. // CHECK:STDOUT: return <error>
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: