Skip to content
GitLab
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 5,347
    • Issues 5,347
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 571
    • Merge requests 571
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #5892
Closed
Open
Issue created Feb 22, 2012 by parcs@trac-parcs

Compiler crash and other oddities when using RecordWildCards with record accessors not imported

GHC exhibits an irrefutable pattern failure when attempting to compile or interpret a module that uses the RecordWildCards extension to bind a record's field names when its field accessors are not in scope.

Error:

*** Exception: compiler/rename/RnPat.lhs:535:39-79: Irrefutable pattern failed for pattern gres@(gre : _)

Examples:

{-# LANGUAGE RecordWildCards #-}
import Data.Tree (Tree(Node))
-- Note that Node's record accessors 'subForest' and 'rootLabel' are not imported.

Node{..} = Node () []
{-# LANGUAGE RecordWildCards #-}
import Data.Tree (Tree(Node))

foo = let rootLabel = (); subForest = [] in Node{..}

With GHC HEAD + a trivial patch for RnPat.lhs the programs compiled but other oddities appeared. With the patch, the first program does not have the names 'subForest' and 'rootLabel' in scope, and the second program causes GHCi to complain that the names 'rootLabel' and 'subForest' are unused, and that the fields 'Data.Tree.rootLabel' and 'Data.Tree.subForest' are not initialized in the constructor 'Node'.

I'm not sure what the correct behavior should be in these edge cases but thankfully I found a workaround in my program. (I was using RecordWildCards to extract the fields of Text.Parsec.Token.TokenParser on to the top level. If I don't import its record accessors I get the described error, and if I import the accessors unqualified I get ambiguous name errors, so instead I just import them qualified.)

Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited Mar 09, 2019 by parcs
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking