fail_scope.carbon 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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: imports {
  37. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  38. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = %Core
  44. // CHECK:STDOUT: .Class = %Class.decl
  45. // CHECK:STDOUT: .G = %G.decl
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.import = import Core
  48. // CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
  49. // CHECK:STDOUT: import Core//prelude
  50. // CHECK:STDOUT: import Core//prelude/operators
  51. // CHECK:STDOUT: import Core//prelude/types
  52. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  53. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  54. // CHECK:STDOUT: import Core//prelude/operators/comparison
  55. // CHECK:STDOUT: import Core//prelude/types/bool
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  58. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  59. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  60. // CHECK:STDOUT: %.loc17_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  61. // CHECK:STDOUT: %.loc17_11.2: type = converted %int.make_type_32, %.loc17_11.1 [template = i32]
  62. // CHECK:STDOUT: @G.%return: ref i32 = var <return slot>
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: class @Class {
  67. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  68. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  69. // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
  70. // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32, %.loc12_13.1 [template = i32]
  71. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !members:
  75. // CHECK:STDOUT: .Self = constants.%Class
  76. // CHECK:STDOUT: .F = %F.decl
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: fn @F() -> i32 {
  82. // CHECK:STDOUT: !entry:
  83. // CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.3]
  84. // CHECK:STDOUT: return %.loc13
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: fn @G() -> i32 {
  88. // CHECK:STDOUT: !entry:
  89. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
  90. // CHECK:STDOUT: return <error>
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: