cabal icon indicating copy to clipboard operation
cabal copied to clipboard

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

Open ffaf1 opened this issue 3 years ago • 2 comments

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

To Reproduce

name: pkg
synopsis: synopsis
description: description
version: 0
category: example
maintainer: [email protected]
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

ffaf1 avatar Jun 22 '22 14:06 ffaf1

Same goes for benchmark stanza.

ffaf1 avatar Jun 22 '22 14:06 ffaf1

The parser is a mess.

andreasabel avatar Jul 28 '22 18:07 andreasabel