Description
#10525 made this mistake an error in cabal.project
files:
source-repository-package:
type: git
location: https://github.com/parsonsmatt/foundation
tag: 688c32ccd9a951bc96dd09423a6e6684f091d510
subdir: basement
subdir: foundation
Now, it prints this error:
Error: [Cabal-7090]
Error parsing project file cabal.project:52:
'source-repository-package' is a stanza, not a field. Remove the trailing ':' to parse a stanza.
Unfortunately, .cabal
files use a ~completely different system for parsing, so the fix in #10525 doesn't apply to those!
Implementation strategy
For parsing cabal.project
, the parseFieldsAndSections
function (which #10525 modifies to error when stanzas are used as fields) is used with a list of top-level fields and a list of top-level stanzas (which themselves contain a grammar) to parse the file:
cabal/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs
Lines 1250 to 1256 in 5ec4dd1
E.g. Here's the section description for source-repository-package
:
cabal/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs
Lines 1805 to 1826 in 5ec4dd1
And here's the grammar for the fields contained in a source-repository-package
:
cabal/cabal-install/src/Distribution/Client/Types/SourceRepo.hs
Lines 101 to 120 in 5ec4dd1
However, for .cabal
files, the top-level grammar is defined manually:
cabal/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs
Lines 97 to 161 in 5ec4dd1
And the goSections
parsing function just handles each field name manually:
So we should adapt those into the system used by cabal.project
.
Activity