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,977
    • Issues 4,977
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 482
    • Merge requests 482
  • 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
  • #16735
Closed
Open
Created Jun 02, 2019 by nfrisby@trac-nfrisby

Prevent `rewriteEvidence` from converting a W into a WD

Summary

(This is true in 8.6.5 and also right now at 6febc444.)

https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/typecheck/TcCanonical.hs#L2226 declares rewriteEvidence with the comment that "rewriteEvidence old_ev new_pred co ... Returns a new_ev : new_pred, with same wanted/given/derived flag as old_ev".

However, the CtWanted case just immediately calls newWanted, which ignores the incoming ctev_nosh flag and always uses WDeriv.

rewriteEvidence ev@(CtWanted { ctev_dest = dest

                             , ctev_loc = loc }) new_pred co 

= do { mb_new_ev <- newWanted loc new_pred

Thus I'm seeing a [W] become a [WD], which seems to contradict the comment's "same flag" claim.

Steps to reproduce

Unfortunately, my only repro involves a plugin I'm developing. The constraint solver is looping unproductively because my plugin keeps discarding the (re-)emitted [D] shadow as a tautology, then the [W] "unsplits" during canonicalization (even though my plugin didn't touch the [W]), this re-emits the same [D] (via a fundep), and so on.

(See the -ddump-tc-trace snippet in first comment below.)

Expected behavior

rewriteEvidence should create a [W] from a [W].

Environment

  • GHC version used: GHC-8.6.5
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking