Skip to content

main-is: inside two-way if/else: Ambiguous values for modulePath field #9659

@jwaldmann

Description

@jwaldmann

Describe the bug

cabal file containing

executable foo-bar
 if flag(wat)
     main-is: bar-foo.hs
 else
     main-is: foo-bar.hs

is rejected with

Ambiguous values for modulePath field: '"bar-foo.hs"' and '"foo-bar.hs"'
CallStack (from HasCallStack):
  error, called at src/Distribution/Types/UnqualComponentName.hs:128:7 in Cabal-syntax-3.11.0.0-inplace:Distribution.Types.UnqualComponentName

To Reproduce

$ cat foo.cabal
cabal-version: 3.0
name: foo
version: 0

flag wat
  default: False
  manual: True
     
executable foo-bar
 if flag(wat)
     main-is: bar-foo.hs
 else
     main-is: foo-bar.hs
 hs-source-dirs: src
 build-depends: base

$ cabal install

Expected behavior
builds

System information

6.6.12-200.fc39.x86_64  x86_64 GNU/Linux

cabal-install version 3.11.0.0
compiled using version 3.11.0.0 of the Cabal library 

ghc-9.6.3

Additional context

with cabal-install 3.10.2.1, the problem can be repaired with indenting else, see. ucsd-progsys/liquidhaskell#2258 (comment) but cabal-install-3.11 will reject that with

Warning: foo.cabal:12:4: invalid subsection "else"
Warning: foo.cabal:12:4: Inconsistent indentation. Indentation jumps at lines 12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions