Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,256
    • Issues 4,256
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 394
    • Merge Requests 394
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14078

Closed
Open
Opened Aug 02, 2017 by dramforever@dramforever

-ddump-json doesn't work well with GHCi

Currently, :set -ddump-json in GHCi causes all errors to be gathered to be written out on exit. ghci -ddump-json is even worse, only resulting in a [] being output on exit.

However, I believe this completely defeats the purpose of this flag in GHCi. I expect ghci -ddump-json to work like this: for each evaluation typed at the GHCi prompt, one JSON array is output for all messages this evaluation caused.

This proposed behavior is consistent with other flags like -ddump-simpl, and will allow tooling to interact with GHCi nicely.

Reporting this as a bug because this looks half-supported rather than unsupported, and also because of the different behaviors of ghci -ddump-json and :set -ddump-json. Sorry if it was not warranted.

Steps to reproduce

cmd> is the shell prompt.

cmd> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.1

cmd> type tmp.hs
main = print 2 + 2

cmd> ghci -ddump-json tmp.hs
GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( tmp.hs, interpreted )

tmp.hs:1:8: error:
    ? No instance for (Num (IO ())) arising from a use of ‘+’
    ? In the expression: print 2 + 2
      In an equation for ‘main’: main = print 2 + 2
  |
1 | main = print 2 + 2
  |        ^^^^^^^^^^^
Failed, 0 modules loaded.
Prelude> :q
Leaving GHCi.
[]

cmd> ghci
GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
Prelude> :set -ddump-json
Prelude> :l tmp.hs
[1 of 1] Compiling Main             ( tmp.hs, interpreted )

tmp.hs:1:8: error:
    ? No instance for (Num (IO ())) arising from a use of ‘+’
    ? In the expression: print 2 + 2
      In an equation for ‘main’: main = print 2 + 2
  |
1 | main = print 2 + 2
  |        ^^^^^^^^^^^
Failed, 0 modules loaded.
Prelude> :q
Leaving GHCi.
[
 {"span": {"file": "tmp.hs","startLine": 1,"startCol": 8,"endLine": 1,"endCol": 19},"doc": "\u2022 No instance for (Num (IO ())) arising from a use of \u2018+\u2019\n\u2022 In the expression: print 2 + 2\n  In an equation for \u2018main\u2019: main = print 2 + 2","severity": "SevError","reason": null},

 {"span": null,"doc": "[1 of 1] Compiling Main             ( tmp.hs, interpreted )","severity": "SevOutput","reason": null}]
Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.6.1
Milestone
8.6.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14078