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,401
    • Issues 5,401
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 590
    • Merge requests 590
  • 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
  • #20060
Closed
Open
Issue created Jun 29, 2021 by Teo Camarasu@teoContributor

Pattern match failure from GHC when compiling module with -O2 that uses mapM in TH

Summary

The following module causes GHC HEAD and 9.2 to crash with a pattern match failure. It looks like this is triggered from some code turning core into stg in the driver. Interestingly, replacing mapM with traverse causes it to disappear. It doesn't happen if we don't compile the module with -O2.

Steps to reproduce

Try to compile the following module:

{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -O2 #-}
module THBug where

data A
data B

concat <$> mapM (\_ -> (pure []))
  [ ''A
  , ''B
  ]

ghc produces the following output:

[1 of 1] Compiling THBug            ( THBug.hs, THBug.o, THBug.dyn_o )
user error (Pattern match failure in 'do' block at compiler/GHC/Driver/Main.hs:1823:5-68)

Expected behaviour

This module should probably compile without an error

Environment

  • GHC version used:
The Glorious Glasgow Haskell Compilation System, version 9.3.20210628

Optional:

  • Operating System: Linux under WSL2
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking