swiftlang / swift-driver

Swift compiler driver reimplementation in Swift
Apache License 2.0
796 stars 193 forks source link

Duplicate diagnostics being output in Swift 6 #1669

Open award999 opened 4 months ago

award999 commented 4 months ago

Description

With nightly build of swift 6 I keep seeing duplicate error diagnostics getting output. This was showing up intermittently on macOS but is consistent on Linux.

Reproduction

Create a swift executable with "swift package init". Any error should reproduce:

print("Hello, world!")
let f = 1
f = 2

Build and notice the duplicate error diagnostic

$ swift build --build-tests
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/home/vscode/swift-executable/Sources/main.swift:6:1: error: cannot assign to value: 'f' is a 'let' constant
3 | 
4 | print("Hello, world!")
5 | let f = 1
  | - note: change 'let' to 'var' to make it mutable
6 | f = 2
  | - error: cannot assign to value: 'f' is a 'let' constant
7 | 
/home/vscode/swift-executable/Sources/main.swift:6:1: error: cannot assign to value: 'f' is a 'let' constant
3 | 
4 | print("Hello, world!")
5 | let f = 1
  | - note: change 'let' to 'var' to make it mutable
6 | f = 2
  | - error: cannot assign to value: 'f' is a 'let' constant
7 |

Same when using "llvm" format:

$ swift build -Xswiftc -diagnostic-style=llvm
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/home/vscode/swift-executable/Sources/main.swift:6:1: error: cannot assign to value: 'f' is a 'let' constant
f = 2
^
/home/vscode/swift-executable/Sources/main.swift:5:1: note: change 'let' to 'var' to make it mutable
let f = 1
^~~
var
/home/vscode/swift-executable/Sources/main.swift:6:1: error: cannot assign to value: 'f' is a 'let' constant
f = 2
^
/home/vscode/swift-executable/Sources/main.swift:5:1: note: change 'let' to 'var' to make it mutable
let f = 1
^~~
var

Expected behavior

No duplicate diagnostics

Environment

Using the swiftlang/swift:nightly-6.0-jammy docker image $ swift -version Swift version 6.0-dev (LLVM 4b0b1f9e1a69523, Swift 91a3abcf816bc36) Target: aarch64-unknown-linux-gnu

Additional information

No response

MaxDesiatov commented 2 months ago

Also tracked as rdar://131732364.

finagolfin commented 2 months ago

Heh, this issue is being passed around like a hot potato. 😃