Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13640] Duplicate diagnostics when using 'swift build' #4494

Open
ackyshake mannequin opened this issue Oct 1, 2020 · 1 comment
Open

[SR-13640] Duplicate diagnostics when using 'swift build' #4494

ackyshake mannequin opened this issue Oct 1, 2020 · 1 comment
Labels

Comments

@ackyshake
Copy link
Mannequin

ackyshake mannequin commented Oct 1, 2020

Previous ID SR-13640
Radar rdar://problem/69845492
Original Reporter @ackyshake
Type Bug
Environment

OS: macOS 11.0 (Build 20A5384c)

Swift: Apple Swift version 5.3.1 (swiftlang-1200.0.39 clang-1200.0.32.6)
Target: x86_64-apple-darwin20.1.0

Xcode: Version 12.2 beta 2 (12B5025f)

Additional Detail from JIRA
Votes 0
Component/s Compiler, Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 2414cf1601592c74d817051b25d951c4

Issue Description:

Hi there,

I've noticed duplicate error diagnostics from the compiler when I try to use swift build to compile my projects, for some time now. Notably, the spurious duplication of diagnostics are only visible in the Terminal. In Xcode, diagnostic messages, if any, are unique.

Note that my current environment is a beta OS with Xcode 12.2. However, this has been an issue ever since swiftpm was released, and is reproducible in macOS Catalina with Xcode 11 and Swift 5.

As an example, I cloned swift-argument-parser at tag 0.3.1, and intentionally introduced a typo in two lines like so:

[ajh@Bessie:~/Developer/vendor/swift-argument-parser]% git diff
diff --git a/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift b/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift
index 3ec9e54..1d2aa84 100644
--- a/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift
+++ b/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift
@@ -11,7 +11,7 @@ struct BashCompletionsGenerator {
   /// Generates a Bash completion script for the given command.
-  static func generateCompletionScript(_ type: ParsableCommand.Type) -> String {
+  static func generateCompletionScript(_ type: ParsableCommand.Type) -> Stringt {
     // TODO: Add a check to see if the command is installed where we expect?
     let initialFunctionName = [type].completionFunctionName()
     return """
@@ -24,7 +24,7 @@ struct BashCompletionsGenerator {
   }   /// Generates a Bash completion function for the last command in the given list.
-  fileprivate static func generateCompletionFunction(_ commands: [ParsableCommand.Type]) -> String {
+  fileprivate static func generateCompletionFunction<T>(_ commands: [ParsableCommand.Type]) -> String {
     let type = commands.last!
     let functionName = commands.completionFunctionName()

Next, I invoked swift build.

I would expect two diagnostic messages from the compiler, one for each of the errors I introduced. However, I get three diagnostic messages, one of them, a duplicate:

[ajh@Bessie:~/Developer/vendor/swift-argument-parser]% swift build
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:14:73: error: cannot find type 'Stringt' in scope
  static func generateCompletionScript(_ type: ParsableCommand.Type) -> Stringt {
                                                                        ^~~~~~~
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:14:73: error: cannot find type 'Stringt' in scope
  static func generateCompletionScript(_ type: ParsableCommand.Type) -> Stringt {
                                                                        ^~~~~~~
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:27:54: error: generic parameter 'T' is not used in function signature
  fileprivate static func generateCompletionFunction<T>(_ commands: [ParsableCommand.Type]) -> String {
                                                     ^
[2/6] Compiling ArgumentParser BashCompletionsGenerator.swift

Moreover, if I use swift build --jobs 1, I get even more duplicates:

[1 ajh@Bessie:~/Developer/vendor/swift-argument-parser]% swift build --jobs 1
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:14:73: error: cannot find type 'Stringt' in scope
  static func generateCompletionScript(_ type: ParsableCommand.Type) -> Stringt {
                                                                        ^~~~~~~
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:27:54: error: generic parameter 'T' is not used in function signature
  fileprivate static func generateCompletionFunction<T>(_ commands: [ParsableCommand.Type]) -> String {
                                                     ^
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:14:73: error: cannot find type 'Stringt' in scope
  static func generateCompletionScript(_ type: ParsableCommand.Type) -> Stringt {
                                                                        ^~~~~~~
/Users/ajh/Developer/vendor/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:27:54: error: generic parameter 'T' is not used in function signature
  fileprivate static func generateCompletionFunction<T>(_ commands: [ParsableCommand.Type]) -> String {
                                                     ^
[2/6] Compiling ArgumentParser CompletionsGenerator.swift

I have several targets in my one of my own projects (however I cannot share this project), and I get over 10 duplicate diagnostic messages for one line of error.

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants