adaszko / complgen

Declarative bash/fish/zsh completions without writing shell scripts
Apache License 2.0
221 stars 7 forks source link

Warning: Final DFA contains ambiguous transitions #40

Closed adaszko closed 8 months ago

adaszko commented 9 months ago

For the grammar cmd ({{{ echo foo }}} | {{{ echo bar }}});, the following warning gets produced:

Warning: Final DFA contains ambiguous transitions; inputs: [Command(u!("echo foo"), 0), Command(u!("echo bar"), 0)]

Diagnosis: In order to proceed with matching command line words, complgen needs to be able to tell what {{{ echo foo }}} returned but that information gets lost between invocations of the completion functions and therefore it cannot work (it would be too complicated even if it memoized it).

Fix: Allow elements like {{{ ... }}} and <NONTERM>, where <NONTERM> expands to some external command, to only occur at the final position in any alternative (|), fallback (||), repetition (...) or optional ([...]) expression. Also allow the above elements to only occur at the final position in subword expressions. Examples: