Error parsing if/else block in test-suite stanza of cabal file
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Using an `if`/`else` block to provide alternative `main-is` values in the test-suite stanza results in a parsing error:
> Test suite "cabal-bug" is missing required field "type" or the field is not present in all conditional branches.
[Minimal reproducible example.](https://gist.github.com/nghamilton/0a2240a189f66432ea090027b27f7469)
A workaround is to include `type` field in both branches, as suggested by the error message:
```
if flag(breaks)
main-is: Main1.hs
type: exitcode-stdio-1.0
else
main-is: Main2.hs
type: exitcode-stdio-1.0
```
If this is the expected behavior, the error message could possibly be expressed more clearly, or the documentation could state the `type` field should be present in all conditional branches.
Tested on cabal version 3.0.0.
Contributor guide
Assessment
This issue has not been assessed yet.