diff options
| -rw-r--r-- | compiler/GHC/Core/Lint.hs | 12 | ||||
| -rw-r--r-- | testsuite/tests/corelint/T21152.hs | 8 | ||||
| -rw-r--r-- | testsuite/tests/corelint/all.T | 1 |
3 files changed, 20 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Lint.hs b/compiler/GHC/Core/Lint.hs index 688b63ff55..32d109b2f1 100644 --- a/compiler/GHC/Core/Lint.hs +++ b/compiler/GHC/Core/Lint.hs @@ -945,7 +945,17 @@ lintCoreExpr e@(App _ _) ; checkCanEtaExpand fun args app_ty ; return app_pair} where - (fun, args) = collectArgs e + (fun, args, _source_ticks) = collectArgsTicks tickishFloatable e + -- We must look through source ticks to avoid #21152, for example: + -- + -- reallyUnsafePtrEquality + -- = \ @a -> + -- (src<loc> reallyUnsafePtrEquality#) + -- @Lifted @a @Lifted @a + -- + -- To do this, we use `collectArgsTicks tickishFloatable` to match + -- the eta expansion behaviour, as per Note [Eta expansion and source notes] + -- in GHC.Core.Opt.Arity. lintCoreExpr (Lam var expr) = markAllJoinsBad $ diff --git a/testsuite/tests/corelint/T21152.hs b/testsuite/tests/corelint/T21152.hs new file mode 100644 index 0000000000..6722d95267 --- /dev/null +++ b/testsuite/tests/corelint/T21152.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE MagicHash #-} + +module T21152 where + +import GHC.Exts ( Int#, reallyUnsafePtrEquality# ) + +reallyUnsafePtrEquality :: a -> a -> Int# +reallyUnsafePtrEquality = reallyUnsafePtrEquality# diff --git a/testsuite/tests/corelint/all.T b/testsuite/tests/corelint/all.T index 2f8b9070ec..1b53c188be 100644 --- a/testsuite/tests/corelint/all.T +++ b/testsuite/tests/corelint/all.T @@ -2,3 +2,4 @@ setTestOpts(extra_hc_opts('-package ghc')) setTestOpts(extra_run_opts('"' + config.libdir + '"')) test('LintEtaExpand', normal, compile_and_run, ['']) +test('T21152', normal, compile, ['-g3']) |
