fail_namespace_conflict.carbon 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 [NameDeclDuplicate]
  12. // CHECK:STDERR: var A: ();
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
  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 [NameDeclDuplicate]
  20. // CHECK:STDERR: var A: () = ();
  21. // CHECK:STDERR: ^
  22. // CHECK:STDERR: fail_namespace_conflict.carbon:[[@LINE-14]]:1: note: name is previously declared here [NameDeclPrevious]
  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: %empty_tuple.type: type = tuple_type () [template]
  30. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = 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: %A.var.loc20: ref %empty_tuple.type = var A
  39. // CHECK:STDOUT: %A.loc20: ref %empty_tuple.type = bind_name A, %A.var.loc20
  40. // CHECK:STDOUT: %A.var.loc28: ref %empty_tuple.type = var A
  41. // CHECK:STDOUT: %A.loc28: ref %empty_tuple.type = bind_name A, %A.var.loc28
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @__global_init() {
  45. // CHECK:STDOUT: !entry:
  46. // CHECK:STDOUT: %.loc28_14.1: %empty_tuple.type = tuple_literal ()
  47. // CHECK:STDOUT: %.loc28_14.2: init %empty_tuple.type = tuple_init () to file.%A.var.loc28 [template = constants.%empty_tuple]
  48. // CHECK:STDOUT: %.loc28_15: init %empty_tuple.type = converted %.loc28_14.1, %.loc28_14.2 [template = constants.%empty_tuple]
  49. // CHECK:STDOUT: assign file.%A.var.loc28, %.loc28_15
  50. // CHECK:STDOUT: return
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: