haskell / haskell/cabal

Leading blank spaces are confusing

Open
#9,757 1 comment 0 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
Typically package descriptions are aligned to the left. However they don't have to be — leading blank spaces are allowed. This seems harmless; you could indent the whole file if you want to and it would still work. However it can be a bit surprising that things can be indented less than the thing before them.

**To Reproduce**
Build the following package description:

``` cabal
cabal-version: 3.8
name: example
version: 0
library
```

**Expected behavior**
I would expect this to be an error, or at least a warning. A field or section probably should not be allowed to be indented less than the item before it.

**System information**
``` sh
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.8.1

$ cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library
```

**Additional context**
I'm not totally sure this is a bug, but the behavior was surprising to me. Perhaps it should just be documented somewhere.

Note that you _can't_ do this:

``` cabal
cabal-version: 3.8
name: example
version: 0
```

That's because `version: 0` is interpreted as part of the `name`'s value since it's indented more than the `name`. This shows that there's nothing special about the indentation of the first line/field/section.

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.