fail_namespace_conflict.carbon 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/var/no_prelude/fail_namespace_conflict.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon
  10. namespace A;
  11. // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+7]]:5: ERROR: Duplicate name being declared in the same scope.
  12. // CHECK:STDERR: var A: ();
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-5]]:1: Name is previously declared here.
  15. // CHECK:STDERR: namespace A;
  16. // CHECK:STDERR: ^~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. var A: ();
  19. // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE+6]]:5: ERROR: Duplicate name being declared in the same scope.
  20. // CHECK:STDERR: var A: () = ();
  21. // CHECK:STDERR: ^
  22. // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-14]]:1: Name is previously declared here.
  23. // CHECK:STDERR: namespace A;
  24. // CHECK:STDERR: ^~~~~~~~~~~~
  25. var A: () = ();
  26. // CHECK:STDOUT: --- fail_namespace_conflict.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  30. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .A = %A.loc11
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %A.loc11: <namespace> = namespace [template] {}
  38. // CHECK:STDOUT: %.loc20_9.1: %.1 = tuple_literal ()
  39. // CHECK:STDOUT: %.loc20_9.2: type = converted %.loc20_9.1, constants.%.1 [template = constants.%.1]
  40. // CHECK:STDOUT: %A.var.loc20: ref %.1 = var A
  41. // CHECK:STDOUT: %A.loc20: ref %.1 = bind_name A, %A.var.loc20
  42. // CHECK:STDOUT: %.loc28_9.1: %.1 = tuple_literal ()
  43. // CHECK:STDOUT: %.loc28_9.2: type = converted %.loc28_9.1, constants.%.1 [template = constants.%.1]
  44. // CHECK:STDOUT: %A.var.loc28: ref %.1 = var A
  45. // CHECK:STDOUT: %A.loc28: ref %.1 = bind_name A, %A.var.loc28
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @__global_init() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %.loc28_14.1: %.1 = tuple_literal ()
  51. // CHECK:STDOUT: %.loc28_14.2: init %.1 = tuple_init () to file.%A.var.loc28 [template = constants.%tuple]
  52. // CHECK:STDOUT: %.loc28_15: init %.1 = converted %.loc28_14.1, %.loc28_14.2 [template = constants.%tuple]
  53. // CHECK:STDOUT: assign file.%A.var.loc28, %.loc28_15
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: