@Flag claims to support Bool? but doesn't?
The following should be supported but isn't:
@Flag(help: "...")
var writeEmptyFiles: Bool?
The error is
Referencing initializer 'init(name:help:)' on 'Flag' requires the types 'Bool?' and 'Int' be equivalent
It turns out the inversion parameter is required, so the following works:
@Flag(inversion: .prefixedEnableDisable, help: "")
var writeEmptyFiles: Bool?
this seems somewhat accidental? Are we just missing an initializer with defaulted inversion?
ArgumentParser version: 0.1.0 or the main branch, for example.
Swift version: swift-driver version: 1.139 Apple Swift version 6.2 (swiftlang-6.3.0.101.15 clang-2100.0.101.15); arm64-apple-macosx26.0
Checklist
- [x] Reproduces on main
- [x] I've searched for existing GitHub issues
Steps to Reproduce
The snippets above are enough to repro
Expected behavior
We should support just @Flag() on optional boolean fields
Actual behavior
fails to compile
Seems this is just because we don't provide a default, we should add one -- ill follow up on it
This functionality is supported, but the overloads we have lead to a bad compiler response. I'm not sure if there's a way to improve it, but something that could point out instead that an initial value is required when the type is Bool? would be great!