Skip to content

Disambiguate breaks options which are prefixes of others #419

@munchhausen3435

Description

@munchhausen3435

Discovered the following bug today. I haven't really explored it, but below is a seemingly minimal example:

import Options.Applicative

data Opt = A | B

opts :: Parser Opt
opts = flag' A (long "test") <|> flag' B (long "test1")

main :: IO ()
main = () <$ customExecParser (prefs disambiguate) (info opts mempty)

Let's call this program test. Running test --test yields:

Invalid option `--test'

Did you mean one of these?
    --test
    --test1

Usage: test (--test | --test1)

However, test --test1 executes just fine. Furthermore, replacing main by

main = () <$ execParser (info opts mempty)

parses either option just fine.

I've tried this with the latest versions (0.16.0.0 and 0.16.0.1) and also hopped back to 0.15.0.0 just to see if there was any difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions