fail_local_in_namespace.carbon 3.0 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/alias/no_prelude/fail_local_in_namespace.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/no_prelude/fail_local_in_namespace.carbon
  10. namespace NS;
  11. fn F() -> {} {
  12. // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+8]]:9: error: name `NS` not found [NameNotFound]
  13. // CHECK:STDERR: alias NS.a = {};
  14. // CHECK:STDERR: ^~
  15. // CHECK:STDERR:
  16. // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+4]]:16: error: alias initializer must be a name reference [AliasRequiresNameRef]
  17. // CHECK:STDERR: alias NS.a = {};
  18. // CHECK:STDERR: ^~
  19. // CHECK:STDERR:
  20. alias NS.a = {};
  21. // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+4]]:10: error: member name `a` not found in `NS` [MemberNameNotFoundInScope]
  22. // CHECK:STDERR: return NS.a;
  23. // CHECK:STDERR: ^~~~
  24. // CHECK:STDERR:
  25. return NS.a;
  26. }
  27. // CHECK:STDOUT: --- fail_local_in_namespace.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  31. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  32. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .NS = %NS
  38. // CHECK:STDOUT: .F = %F.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {}
  41. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  42. // CHECK:STDOUT: %return.patt: %empty_struct_type = return_slot_pattern
  43. // CHECK:STDOUT: %return.param_patt: %empty_struct_type = out_param_pattern %return.patt, runtime_param0
  44. // CHECK:STDOUT: } {
  45. // CHECK:STDOUT: %.loc13_12.1: %empty_struct_type = struct_literal ()
  46. // CHECK:STDOUT: %.loc13_12.2: type = converted %.loc13_12.1, constants.%empty_struct_type [template = constants.%empty_struct_type]
  47. // CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param runtime_param0
  48. // CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @F() -> %empty_struct_type {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %.loc22_17: %empty_struct_type = struct_literal ()
  55. // CHECK:STDOUT: %.loc22_12: <error> = bind_alias <none>, <error> [template = <error>]
  56. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  57. // CHECK:STDOUT: %a.ref: <error> = name_ref a, <error> [template = <error>]
  58. // CHECK:STDOUT: return <error>
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: