haskell / haskell/cabal

Wrong parse error when `main-is` missing from `test-suite`

Open
#8,246 2 comments 1 reaction 0 assignees View on GitHub
attention: pr-welcome Cabal: parser type: bug weird bug award
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
In a file with a missing `main-is` in `test-suite`, parser incorrectly complains about wrong or missing `type`

**To Reproduce**

```cabal-version: 3.0
name: pkg
synopsis: synopsis
description: description
version: 0
category: example
maintainer: none@example.com
license: GPL-3.0-or-later

test-suite test
-- main-is: Main.hs
type: exitcode-stdio-1.0
default-language: Haskell2010
```

```
Warning: pkg.cabal:10:1: Test suite "test" is missing required field "type" or
the field is not present in all conditional branches. The available test types
are: exitcode-stdio-1.0, detailed-0.9
Warning: pkg.cabal:10:1: The 'main-is' field is required for the
exitcode-stdio-1.0 test suite type.
Errors encountered when parsing cabal file ./pkg.cabal:

pkg.cabal:10:1: error:
Test suite "test" is missing required field "type" or the field is not present in all conditional branches. The available test types are: exitcode-stdio-1.0, detailed-0.9

8 | license: GPL-3.0-or-later
9 |
10 | test-suite test
| ^

pkg.cabal:10:1: error:
The 'main-is' field is required for the exitcode-stdio-1.0 test suite type.

8 | license: GPL-3.0-or-later
9 |
10 | test-suite test
| ^
Error: cabal: parse error
```

**Expected behavior**
Complain about the right stuff (`main-is` missing) or leave it to `cabal check`, etc.

**System information**
- debian linux
- cabal-install 3.9 HEAD

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.