fail_not_found.carbon 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 `package` [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: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  34. // CHECK:STDOUT: %facet_value: %type_where = facet_value %i32, () [concrete]
  35. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d4e: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [concrete]
  36. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.424: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d4e = struct_value () [concrete]
  37. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %DestroyT.binding.as_type.as.Destroy.impl.Op.424, @DestroyT.binding.as_type.as.Destroy.impl.Op(%facet_value) [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  42. // CHECK:STDOUT: .Int = %Core.Int
  43. // CHECK:STDOUT: .Destroy = %Core.Destroy
  44. // CHECK:STDOUT: import Core//prelude
  45. // CHECK:STDOUT: import Core//prelude/...
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  48. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  53. // CHECK:STDOUT: .Core = imports.%Core
  54. // CHECK:STDOUT: .Main = %Main.decl
  55. // CHECK:STDOUT: .x = <poisoned>
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %Core.import = import Core
  58. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: fn @Main() {
  62. // CHECK:STDOUT: !entry:
  63. // CHECK:STDOUT: name_binding_decl {
  64. // CHECK:STDOUT: %y.patt: %pattern_type.7ce = ref_binding_pattern y [concrete]
  65. // CHECK:STDOUT: %y.var_patt: %pattern_type.7ce = var_pattern %y.patt [concrete]
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %y.var: ref %i32 = var %y.var_patt
  68. // CHECK:STDOUT: %package.ref: <namespace> = name_ref package, package [concrete = package]
  69. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  70. // CHECK:STDOUT: assign %y.var, <error>
  71. // CHECK:STDOUT: %.loc20: type = splice_block %i32 [concrete = constants.%i32] {
  72. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  73. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %y: ref %i32 = ref_binding y, %y.var
  76. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %y.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.424
  77. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.424, @DestroyT.binding.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn]
  78. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %y.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn
  79. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%y.var)
  80. // CHECK:STDOUT: return
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: