Skip to content

Use of plugins causes different SafeHaskellMode returned for the module

Use of plugins will mark safe inference as failed, even when the plugin does not modify anything. This can result in compile error when -XSafe is used. For example:

$ cat DefaultPlugin.hs
module DefaultPlugin (plugin) where
import GhcPlugins
plugin = defaultPlugin

$ cat B.hs
{-# OPTIONS_GHC -fplugin DefaultPlugin #-}
module B (answer) where
answer = 42

$ cat A.hs
{-# LANGUAGE Safe #-}
module A (main) where
import B
main = print answer

$ ...
A.hs:4:1: error:
    B: Can't be safely imported! The module itself isn't safe.
Trac metadata
Trac field Value
Version 8.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Zejun Wu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information