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,932
    • Issues 4,932
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 464
    • Merge requests 464
  • 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
  • Merge requests
  • !7788

Draft: Don't inline newtype DFuns (#21229)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Sebastian Graf requested to merge wip/T21229 into master Mar 15, 2022
  • Overview 51
  • Commits 2
  • Pipelines 17
  • Changes 25

Our work on #21229 (closed) uncovered a way in which Specialise could produce unsound specialisations, ultimately caused by reboxing of newtype dictionaries.

In the case of datatypes, we carefully avoid this through the mechanism in Note [ClassOp/DFun selection] that refrains from inlining a DFun. This patch uses the same mechanism for newtype dictionaries, thus upholding the new Note [Do not inline dictionary selectors].

I also had to adapt GHC.Tc.Instance.Class.makeLitDict to produce a call to a DFun, GHC.TypeNats.natDict @0 (SNat (NS 0##)) instead of producing the necessary evidence of the form MkKnownNat (SNat (NS 0##)) directly. That is because the latter will no longer rewrite with Note [ClassOp/DFun selection] (it is not a DFun, after all), regressing T14170.

The new natDict (resp. symbolDict, charDict) bindings are implemented via Note [Patching magic definitions] and thus need to add a few known-key things.

  • Fixes #21229 (closed).
  • See also #21328 (closed)
Edited May 02, 2022 by Simon Peyton Jones
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: wip/T21229