Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19559
Closed
Open
Created Mar 18, 2021 by Roland Senn@RolandSennDeveloper

The GHCi debugger loses type constraints

Summary

The GHCi debugger loses the type constraints of the breakpoint variables..

Steps to reproduce

Foo.hs is a simplified version of testcase break012:

foo :: (Num a1, Num a2) => a2 -> (a2, a1 -> a1 -> a1)
foo i = let incr = i + 1
            add = (+)
        in (incr,add)

Observe the following GHCi session:

$ ghci Foo.hs
GHCi, version 9.0.1: https://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( Foo.hs, interpreted )
Ok, one module loaded.
ghci> :st foo 5 `seq` ()
Stopped in Main.foo, Foo.hs:4:12-21
_result :: (a2, a1 -> a1 -> a1) = _
add :: a1 -> a1 -> a1 = _
incr :: a2 = _
[Foo.hs:4:12-21] ghci> add 40 2

<interactive>:2:5: error:
    • No instance for (Num a1) arising from the literal ‘40’
      Cannot resolve unknown runtime type ‘a1’
      Use :print or :force to determine these types
      Relevant bindings include it :: a1 (bound at <interactive>:2:1)
      These potential instances exist:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘add’, namely ‘40’
      In the expression: add 40 2
      In an equation for ‘it’: it = add 40 2
[Foo.hs:4:12-21] ghci>

The types of all breakpoint variables lack Num contraints!

Expected behavior

The types of the 2 breakpoint variables (_result, add) should have a Num constraint for a1. The type of incr should be Integer. The correct types are:

_result :: Num a1 => Integer -> (Integer, a1 -> a1 -> a1) = _  
add :: Num a1 => a1 -> a1 -> a1 = _
incr :: Integer = _

The result of add 40 2 should be 42 and not an error message.

Environment

  • GHC versions used: 7.10.3, 8.10.2, 9.0.1, HEAD (in 7.10.3 only the _result breakpoint variable is shown)
  • Operating System: Linux Debian 10
  • System Architecture: x86_64
Edited Nov 11, 2021 by Roland Senn
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking