Emit compile-time error if the derive interface produces duplicate short/long arguments #3592
Closed
2 tasks done
Labels
C-enhancement
Category: Raise on the bar on expectations
Please complete the following tasks
Clap Version
3.1.3
Describe your use case
Not much special context for the use case, reasoning behind the feature is given below.
Describe the solution you'd like
Given the following code (playground):
clap will successfully detect at runtime that
arg1
andarg2
have the duplicate short form-a
:With clap's derive interface, it seems like this could be caught at compile time when the proc macro executes on
Args
, by producing a compiler error if it picks up on duplicate short (or long) names.This would give much quicker feedback for programmer error. Also, since clap only checks for argument uniqueness in debug mode, if you're only ever running a release build of your binary you won't actually hit this panic.
Alternatives, if applicable
I personally wouldn't mind it if the assertions were enabled in release builds, but the compile-time approach seems better as it avoids the runtime overhead.
Additional Context
We were mostly only running our binary in release mode, and we went a few days with duplicate short arguments. When we hit the panic, it wasn't immediately obvious what was going on.
The text was updated successfully, but these errors were encountered: