.cabal
files: Make a trailing colon for stanzas a parse failure
#10660
Labels
re: user experience
User experience (UX) issue
#10525 made this mistake an error in
cabal.project
files:Now, it prints this error:
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
, theparseFieldsAndSections
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:cabal/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs
Line 286 in 5ec4dd1
So we should adapt those into the system used by
cabal.project
.The text was updated successfully, but these errors were encountered: