swiftlang / swift-docc-plugin

Swift Package Manager command plugin for Swift-DocC
https://swiftpackageindex.com/apple/swift-docc-plugin/1.3.0/documentation/swiftdoccplugin
Apache License 2.0
316 stars 54 forks source link

fatal compiler error on swift 5.7 and Swift 5.8 #94

Closed sebsto closed 2 weeks ago

sebsto commented 2 weeks ago

Description

using Swift Docc plugin 1.0.0, I receive fatal compilation error from Swift on 5.7 and 5.8

19:03:38 [2/2] Compiling plugin Swift-DocC
19:03:38 error: fatalError

or

19:01:05 Compiling plugin Swift-DocC...
19:01:05 error: emit-module command failed with exit code 1 (use -v to see invocation)
19:01:05 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:31:50: error: consecutive declarations on a line must be separated by ';'
19:01:05     private var remainingOptionsOrFlags: [String].SubSequence
19:01:05                                                  ^
19:01:05                                                  ;
19:01:05 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:31:50: error: expected declaration
19:01:05     private var remainingOptionsOrFlags: [String].SubSequence
19:01:05                                                  ^
19:01:05 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:12:15: note: in declaration of 'CommandLineArguments'
19:01:05 public struct CommandLineArguments {
19:01:05               ^
19:01:05 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:34:40: error: consecutive declarations on a line must be separated by ';'
19:01:05     private var literalValues: [String].SubSequence
19:01:05                                        ^
19:01:05                                        ;
19:01:05 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:34:40: error: expected declaration
19:01:05     private var literalValues: [String].SubSequence
19:01:05                                        ^
19:01:05 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:12:15: note: in declaration of 'CommandLineArguments'
19:01:05 public struct CommandLineArguments {
19:01:05               ^
19:01:05 error: fatalError

This breaks our pipeline for The Swift Lambda runtime, see the automated tests for this PR : https://github.com/swift-server/swift-aws-lambda-runtime/pull/342

Checklist

Expected Behavior

Should compile on last 3 Swift versions

Actual behavior

error: fatalError

Steps To Reproduce

Checkout this PR and compile with a 5.7 or 5.8 toolchain

Swift-DocC Version Information

1.0.0

Swift Compiler Version Information

5.7 and 5.8
d-ronnqvist commented 2 weeks ago

Did you mean version 1.4.x of the plugin? Version 1.0.0 doesn't have the code that's referenced in that log output.

Assuming so, you can workaround this error by pinning your swift-docc-plugin dependency to 1.3.0

d-ronnqvist commented 2 weeks ago

I'm on vacation next week, away from a computer, but I can look at this when I get back if no one else has fixed this by then.

sebsto commented 2 weeks ago

Yes, I tried with version 1.0.0 and 1.3.0 of the plugin. both generates fatal errors when trying to compile with swift 5.7 or Swift 5.8

d-ronnqvist commented 2 weeks ago

That makes no sense since the file that those errors are about is 1 day old and the 1.3.0 release is from June 2023

sebsto commented 2 weeks ago

Here is the PR where I observed the error. It looks like the latest version is picked up because of the from

The Package@swift-5.7.swift, Package@swift-5.8.swift, and Package.swift, have all this dependency

.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0")

This is the error from Jenkins logs for Swift 5.7

Compiling plugin Swift-DocC...
19:59:10 error: emit-module command failed with exit code 1 (use -v to see invocation)
19:59:10 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:31:50: error: consecutive declarations on a line must be separated by ';'
19:59:10     private var remainingOptionsOrFlags: [String].SubSequence
19:59:10                                                  ^
19:59:10                                                  ;
19:59:10 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:31:50: error: expected declaration
19:59:10     private var remainingOptionsOrFlags: [String].SubSequence
19:59:10                                                  ^
19:59:10 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:12:15: note: in declaration of 'CommandLineArguments'
19:59:10 public struct CommandLineArguments {
19:59:10               ^
19:59:10 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:34:40: error: consecutive declarations on a line must be separated by ';'
19:59:10     private var literalValues: [String].SubSequence
19:59:10                                        ^
19:59:10                                        ;
19:59:10 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:34:40: error: expected declaration
19:59:10     private var literalValues: [String].SubSequence
19:59:10                                        ^
19:59:10 /code/.build/checkouts/swift-docc-plugin/Plugins/Swift-DocC Convert/Symbolic Links/SwiftDocCPluginUtilities/CommandLineArguments/CommandLineArguments.swift:12:15: note: in declaration of 'CommandLineArguments'
19:59:10 public struct CommandLineArguments {
19:59:10               ^
19:59:10 error: fatalError

This is the error from Jenkins logs for Swift 5.8

19:59:21 [2/2] Compiling plugin Swift-DocC
19:59:21 error: fatalError

I'll force using the 1.3.0 version and report back

sebsto commented 2 weeks ago

My bad, SPM was picking up the latest version (1.4.1) - I forced the exact 1.3.0 version and this solves the problem. I updated the original description to mention plugin version 1.4.1

Kyle-Ye commented 2 weeks ago

I'm on vacation next week, away from a computer, but I can look at this when I get back if no one else has fixed this by then.

I can help fix it. But I think besides it, we need to add some CI check for each PR.

Since the Package.swift is 5.6. We need to add a CI to check build success from 5.6 to 6.0 and main.

Background: swift-docc has updated Package.swift to 5.9 recently swift-markdown has updated Package.swift to 5.7 recently swift-docc-symbolkit which this repo depends has not changed Package.swift yet and still support Swift 5.5+ Maybe we can consider updating Package.swift version to reduce the maintenance cost of CI job.

But sadly GitHub actions are disabled by default in org scope and we need to enable it for this repo or add the CI on ci.swift.org which I do not have permission to contribute.

See related issue and reply here

anferbui commented 2 weeks ago

Since the Package.swift is 5.6. We need to add a CI to check build success from 5.6 to 6.0 and main.

@Kyle-Ye Thank you for pinging that, I don't think we want to be supporting as far back as Swift 5.6 -- as part of my fix, I will update Package.swift to 5.7 :)

Also, +1 on having CI for all the versions we support, to ensure changes are compatible for all.

thomasvl commented 2 weeks ago

Will there be a release soon so projects that had to pin the docc version can unpin?

anferbui commented 2 weeks ago

Just made a new release for swift-docc-plugin to get the fix out as soon as possible: https://github.com/swiftlang/swift-docc-plugin/releases/tag/1.4.2

Pinned projects should now be able to unpin.

thomasvl commented 2 weeks ago

Thank you!