-
Notifications
You must be signed in to change notification settings - Fork 248
Fix crash when running Lint from LegacyMain #267
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
Conversation
Test this and it fixed it. Also couldn't find a way to run |
Hmm, it does not fixed in my environment. $ git rev-parse head
848395f6ba858304f44081d75114ec8506a720d7
$ SWIFTCI_USE_LOCAL_DEPS=1 swift build
dylib (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib) was built
ld: warning: dylib (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib) was built for newer macOS version (10.14.6) than being linked (10.10)
[193/193] Build complete!
$ .build/x86_64-apple-macosx/debug/swift-format --mode lint Package.swift
/Users/user/work/cocoa/swift-format/Package.swift:15:1: warning: [OrderedImports]: sort import statements lexicographically
/Users/user/work/cocoa/swift-format/Package.swift:83:22: warning: remove trailing comma from the last element in single line collection literal
/Users/user/work/cocoa/swift-format/Package.swift:24:18: warning: [RemoveLine]: remove line break
/Users/user/work/cocoa/swift-format/Package.swift:140:2: warning: [RemoveLine]: remove line break
ArgumentParser/Flag.swift:103: Fatal error:
--------------------------------------------------------------------
Can't read a value from a parsable argument definition.
This error indicates that a property declared with an `@Argument`,
`@Option`, `@Flag`, or `@OptionGroup` property wrapper was neither
initialized to a value nor decoded from command-line arguments.
To get a valid value, either call one of the static parsing methods
(`parse`, `parseAsRoot`, or `main`) or define an initializer that
initializes _every_ property of your parsable type.
--------------------------------------------------------------------
zsh: illegal hardware instruction .build/x86_64-apple-macosx/debug/swift-format --mode lint Package.swift
$ echo $?
132 it does not crash while using subcommand mode: $ .build/x86_64-apple-macosx/debug/swift-format lint Package.swift
/Users/user/work/cocoa/swift-format/Package.swift:15:1: warning: [OrderedImports]: sort import statements lexicographically
/Users/user/work/cocoa/swift-format/Package.swift:83:22: warning: remove trailing comma from the last element in single line collection literal
/Users/user/work/cocoa/swift-format/Package.swift:24:18: warning: [RemoveLine]: remove line break
/Users/user/work/cocoa/swift-format/Package.swift:140:2: warning: [RemoveLine]: remove line break
$ echo $?
0
strict flag can be used only non-legacy mode (subcommand mode). $ swift-format --version
0.50500.0
$ swift-format lint --strict Package.swift
/Users/user/work/cocoa/swift-format/Package.swift:15:1: warning: [OrderedImports]: sort import statements lexicographically
/Users/user/work/cocoa/swift-format/Package.swift:83:22: warning: remove trailing comma from the last element in single line collection literal
/Users/user/work/cocoa/swift-format/Package.swift:24:18: warning: [RemoveLine]: remove line break
/Users/user/work/cocoa/swift-format/Package.swift:140:2: warning: [RemoveLine]: remove line break
$ echo $?
1
$ swift-format lint Package.swift
/Users/user/work/cocoa/swift-format/Package.swift:15:1: warning: [OrderedImports]: sort import statements lexicographically
/Users/user/work/cocoa/swift-format/Package.swift:83:22: warning: remove trailing comma from the last element in single line collection literal
/Users/user/work/cocoa/swift-format/Package.swift:24:18: warning: [RemoveLine]: remove line break
/Users/user/work/cocoa/swift-format/Package.swift:140:2: warning: [RemoveLine]: remove line break
$ echo $?
0 |
I meant to say I tested your PR and it didn't crash |
😄 |
Since this only happens with the legacy |
The legacy entry point and Thanks for bringing it up regardless—it was the motivation I needed to kick out the old compatibility mode. 🙂 |
Thanks for the reminder! #276 updates the docs. |
Fix crash bug in LegacyMain lint mode. I test with Xcode 13 and tag 0.50500.0 on macOS 11.6 Intel.
This crash does not happen in using SubCommand lint.
In addition, adds a description of
strict
flag to README.#252 introduces
--strict
, but this flag should be defined in LintFormatOptions.swift, not Lint.swift.