-
Notifications
You must be signed in to change notification settings - Fork 714
Make a trailing colon for stanzas a parse failure #10525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/ProjectConfig/FieldStanzaConfusion/cabal.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# cabal build | ||
Error: [Cabal-7090] | ||
Error parsing project file <ROOT>/cabal.project:4: | ||
'source-repository-package' is a stanza, not a field. Remove the trailing ':' to parse a stanza. |
6 changes: 6 additions & 0 deletions
6
cabal-testsuite/PackageTests/ProjectConfig/FieldStanzaConfusion/cabal.project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
packages: . | ||
|
||
-- This is an error; a trailing `:` is syntax for a field, not a stanza! | ||
source-repository-package: | ||
type: git | ||
location: https://github.com/haskell-hvr/Only |
6 changes: 6 additions & 0 deletions
6
cabal-testsuite/PackageTests/ProjectConfig/FieldStanzaConfusion/cabal.test.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
result <- fails $ cabal' "build" [] | ||
assertOutputContains "Error parsing project file" result | ||
assertOutputContains "'source-repository-package' is a stanza, not a field." result |
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/ProjectConfig/FieldStanzaConfusion/src/MyLib.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module MyLib (someFunc) where | ||
|
||
someFunc :: IO () | ||
someFunc = putStrLn "someFunc" |
13 changes: 13 additions & 0 deletions
13
cabal-testsuite/PackageTests/ProjectConfig/FieldStanzaConfusion/test.cabal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cabal-version: 3.0 | ||
name: test | ||
version: 0.1.0.0 | ||
license: NONE | ||
author: [email protected] | ||
maintainer: Rebecca Turner | ||
build-type: Simple | ||
|
||
library | ||
exposed-modules: MyLib | ||
build-depends: base | ||
hs-source-dirs: src | ||
default-language: Haskell2010 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
synopsis: "A trailing colon after a stanza name in `cabal.project` is now an error" | ||
packages: [cabal-install] | ||
prs: 10525 | ||
--- | ||
|
||
It is now a hard error to use a trailing colon after a stanza name in | ||
`cabal.project` or `*.cabal` files: | ||
|
||
``` | ||
packages: . | ||
|
||
source-repository-package: | ||
type: git | ||
location: https://github.com/haskell/cabal | ||
tag: f34aba976a60940295f41b6649674e9568893894 | ||
``` | ||
|
||
``` | ||
$ cabal build | ||
Error parsing project file cabal.project:3: | ||
'source-repository-package' is a stanza, not a field. Remove the trailing ':' to parse a stanza. | ||
``` | ||
|
||
Previously, the warning message was easily ignored and somewhat misleading, as | ||
the difference between a stanza and a field is not immediately obvious to | ||
Haskellers used to config languages like JSON and YAML (which don't distinguish | ||
between fields which have string or list values and stanzas which have nested | ||
fields): | ||
|
||
``` | ||
Warning: cabal.project: Unrecognized field | ||
'source-repository-package' on line 3 | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.