main-is: inside two-way if/else: Ambiguous values for modulePath field
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**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. https://github.com/ucsd-progsys/liquidhaskell/issues/2258#issuecomment-1910968091 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
```
Contributor guide
Research direction
Start with the provided foo.cabal reproducer and inspect the parsing path around src/Distribution/Types/UnqualComponentName.hs:128, where the ambiguity is reported. Run cabal install with cabal-install 3.11 and confirm that the two-way if/else main-is values are accepted without indentation warnings; done means the example builds as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100