fail_duplicate.carbon 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/interface/no_prelude/fail_duplicate.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon
  10. interface Interface { }
  11. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE+7]]:1: ERROR: Redefinition of interface Interface.
  12. // CHECK:STDERR: interface Interface {
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE-5]]:1: Previous definition was here.
  15. // CHECK:STDERR: interface Interface { }
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. interface Interface {
  19. fn F();
  20. }
  21. fn Function();
  22. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE+7]]:1: ERROR: Duplicate name being declared in the same scope.
  23. // CHECK:STDERR: interface Function;
  24. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  25. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE-5]]:1: Name is previously declared here.
  26. // CHECK:STDERR: fn Function();
  27. // CHECK:STDERR: ^~~~~~~~~~~~~~
  28. // CHECK:STDERR:
  29. interface Function;
  30. class Class;
  31. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE+6]]:1: ERROR: Duplicate name being declared in the same scope.
  32. // CHECK:STDERR: interface Class { }
  33. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  34. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE-5]]:1: Name is previously declared here.
  35. // CHECK:STDERR: class Class;
  36. // CHECK:STDERR: ^~~~~~~~~~~~
  37. interface Class { }
  38. // CHECK:STDOUT: --- fail_duplicate.carbon
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: constants {
  41. // CHECK:STDOUT: %.1: type = interface_type @Interface [template]
  42. // CHECK:STDOUT: %Self.1: %.1 = bind_symbolic_name Self 0 [symbolic]
  43. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  44. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  45. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  46. // CHECK:STDOUT: %Function.type: type = fn_type @Function [template]
  47. // CHECK:STDOUT: %Function: %Function.type = struct_value () [template]
  48. // CHECK:STDOUT: %.3: type = interface_type @.1 [template]
  49. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  50. // CHECK:STDOUT: %.4: type = interface_type @.2 [template]
  51. // CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 0 [symbolic]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: file {
  55. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  56. // CHECK:STDOUT: .Interface = %Interface.decl.loc11
  57. // CHECK:STDOUT: .Function = %Function.decl
  58. // CHECK:STDOUT: .Class = %Class.decl
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %Interface.decl.loc11: type = interface_decl @Interface [template = constants.%.1] {}
  61. // CHECK:STDOUT: %Interface.decl.loc20: type = interface_decl @Interface [template = constants.%.1] {}
  62. // CHECK:STDOUT: %Function.decl: %Function.type = fn_decl @Function [template = constants.%Function] {}
  63. // CHECK:STDOUT: %.decl.loc33: type = interface_decl @.1 [template = constants.%.3] {}
  64. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  65. // CHECK:STDOUT: %.decl.loc43: type = interface_decl @.2 [template = constants.%.4] {}
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: interface @Interface {
  69. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: !members:
  72. // CHECK:STDOUT: .Self = <unexpected instref inst+3>
  73. // CHECK:STDOUT: .F = <error>
  74. // CHECK:STDOUT: witness = ()
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: interface @.1;
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: interface @.2 {
  80. // CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: !members:
  83. // CHECK:STDOUT: .Self = %Self
  84. // CHECK:STDOUT: witness = ()
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: class @Class;
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: fn @F();
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn @Function();
  92. // CHECK:STDOUT: