Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cabal-syntax/src/Distribution/Fields/ParseResult.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ getCabalSpecVersion = PR $ \s@(PRState _ _ v) _fp _failure success ->
-- | Add a warning. This doesn't fail the parsing process.
parseWarning :: Position -> PWarnType -> String -> ParseResult src ()
parseWarning pos t msg = PR $ \(PRState warns errs v) ctx _failure success ->
success (PRState (PWarningWithSource (prContextSource ctx) (PWarning t pos msg) : warns) errs v) ()
success (PRState (warns ++ [PWarningWithSource (prContextSource ctx) (PWarning t pos msg)]) errs v) ()

-- | Add multiple warnings at once.
parseWarnings :: [PWarning] -> ParseResult src ()
parseWarnings newWarns = PR $ \(PRState warns errs v) ctx _failure success ->
success (PRState (map (PWarningWithSource (prContextSource ctx)) newWarns ++ warns) errs v) ()
success (PRState (warns ++ map (PWarningWithSource (prContextSource ctx)) newWarns) errs v) ()

-- | Add an error, but not fail the parser yet.
--
Expand Down
4 changes: 2 additions & 2 deletions Cabal-tests/tests/ParserTests/regressions/common.format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
common.cabal:29:3: Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas
common.cabal:20:3: Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas
common.cabal:14:1: Ignoring section: common. You should set cabal-version: 2.2 or larger to use common stanzas.
common.cabal:20:3: Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas
common.cabal:29:3: Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas
cabal-version: >=1.10
name: common
version: 0
Expand Down
2 changes: 1 addition & 1 deletion Cabal-tests/tests/ParserTests/regressions/elif.format
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
elif.cabal:19:3: invalid subsection "else"
elif.cabal:17:3: invalid subsection "elif". You should set cabal-version: 2.2 or larger to use elif-conditionals.
elif.cabal:19:3: invalid subsection "else"
cabal-version: >=1.10
name: elif
version: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
wl-pprint-indef.cabal:28:3: The field "mixins" is available only since the Cabal specification version 2.0. This field will be ignored.
wl-pprint-indef.cabal:27:3: The field "signatures" is available only since the Cabal specification version 2.0. This field will be ignored.
wl-pprint-indef.cabal:23:3: The field "mixins" is available only since the Cabal specification version 2.0. This field will be ignored.
wl-pprint-indef.cabal:27:3: The field "signatures" is available only since the Cabal specification version 2.0. This field will be ignored.
wl-pprint-indef.cabal:28:3: The field "mixins" is available only since the Cabal specification version 2.0. This field will be ignored.
cabal-version: >=1.6
name: wl-pprint-indef
version: 1.2
Expand Down
10 changes: 10 additions & 0 deletions changelog.d/issue-11269.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
synopsis: Fix parse warnings being emitted in reverse order
packages: [Cabal-syntax]
prs: 11479
issues: 11269
---

Parse warnings were prepended to the accumulator list, causing them to
be emitted in reverse file order. They are now appended so they come out
in file order, consistent with GHC's behavior.
Loading