fail_not_found.carbon 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/package_expr/fail_not_found.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/package_expr/fail_not_found.carbon
  10. fn Main() {
  11. // CHECK:STDERR: fail_not_found.carbon:[[@LINE+4]]:16: error: member name `x` not found in `package` [MemberNameNotFoundInInstScope]
  12. // CHECK:STDERR: var y: i32 = package.x;
  13. // CHECK:STDERR: ^~~~~~~~~
  14. // CHECK:STDERR:
  15. var y: i32 = package.x;
  16. }
  17. // CHECK:STDOUT: --- fail_not_found.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  21. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  22. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  23. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  28. // CHECK:STDOUT: .Int = %Core.Int
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .Main = %Main.decl
  38. // CHECK:STDOUT: .x = <poisoned>
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.import = import Core
  41. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @Main() {
  45. // CHECK:STDOUT: !entry:
  46. // CHECK:STDOUT: name_binding_decl {
  47. // CHECK:STDOUT: %y.patt: %i32 = binding_pattern y
  48. // CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %y.patt
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %y.var: ref %i32 = var y
  51. // CHECK:STDOUT: %package.ref: <namespace> = name_ref package, package [concrete = package]
  52. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  53. // CHECK:STDOUT: assign %y.var, <error>
  54. // CHECK:STDOUT: %.loc16_10: type = splice_block %i32 [concrete = constants.%i32] {
  55. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  56. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: