fail_not_found.carbon 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/package_expr/fail_not_found.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/package_expr/fail_not_found.carbon
  14. fn Main() {
  15. // CHECK:STDERR: fail_not_found.carbon:[[@LINE+4]]:16: error: member name `x` not found in `Main` [MemberNameNotFoundInInstScope]
  16. // CHECK:STDERR: var y: i32 = package.x;
  17. // CHECK:STDERR: ^~~~~~~~~
  18. // CHECK:STDERR:
  19. var y: i32 = package.x;
  20. }
  21. // CHECK:STDOUT: --- fail_not_found.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  25. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  26. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  28. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  29. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  30. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  31. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  32. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  33. // CHECK:STDOUT: %DestroyOp.type: type = fn_type @DestroyOp [concrete]
  34. // CHECK:STDOUT: %DestroyOp: %DestroyOp.type = struct_value () [concrete]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: imports {
  38. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  39. // CHECK:STDOUT: .Int = %Core.Int
  40. // CHECK:STDOUT: .Destroy = %Core.Destroy
  41. // CHECK:STDOUT: import Core//prelude
  42. // CHECK:STDOUT: import Core//prelude/...
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  45. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  50. // CHECK:STDOUT: .Core = imports.%Core
  51. // CHECK:STDOUT: .Main = %Main.decl
  52. // CHECK:STDOUT: .x = <poisoned>
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %Core.import = import Core
  55. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Main() {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: name_binding_decl {
  61. // CHECK:STDOUT: %y.patt: %pattern_type.7ce = ref_binding_pattern y [concrete]
  62. // CHECK:STDOUT: %y.var_patt: %pattern_type.7ce = var_pattern %y.patt [concrete]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %y.var: ref %i32 = var %y.var_patt
  65. // CHECK:STDOUT: %package.ref: <namespace> = name_ref package, package [concrete = package]
  66. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  67. // CHECK:STDOUT: assign %y.var, <error>
  68. // CHECK:STDOUT: %.loc20: type = splice_block %i32 [concrete = constants.%i32] {
  69. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  70. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %y: ref %i32 = ref_binding y, %y.var
  73. // CHECK:STDOUT: %DestroyOp.bound: <bound method> = bound_method %y.var, constants.%DestroyOp
  74. // CHECK:STDOUT: %DestroyOp.call: init %empty_tuple.type = call %DestroyOp.bound(%y.var)
  75. // CHECK:STDOUT: return
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @DestroyOp(%self.param: %i32) = "no_op";
  79. // CHECK:STDOUT: