[Git][ghc/ghc][master] Add regression tests for four StaticPtr bugs
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 530e8e58 by Simon Peyton Jones at 2026-02-12T20:17:23-05:00 Add regression tests for four StaticPtr bugs Tickets #26545, #24464, #24773, #16981 are all solved by the recently-landed MR commit 318ee13bcffa6aa8df42ba442ccd92aa0f7e210c Author: Simon Peyton Jones <simon.peytonjones@gmail.com> Date: Mon Oct 20 23:07:20 2025 +0100 Simplify the treatment of static forms This MR just adds regression tests for them. - - - - - 10 changed files: - + testsuite/tests/rename/should_fail/T26545.hs - + testsuite/tests/rename/should_fail/T26545.stderr - testsuite/tests/rename/should_fail/all.T - + testsuite/tests/typecheck/should_compile/T24464.hs - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_run/T16981.hs - + testsuite/tests/typecheck/should_run/T16981.stdout - + testsuite/tests/typecheck/should_run/T24773.hs - + testsuite/tests/typecheck/should_run/T24773.stdout - testsuite/tests/typecheck/should_run/all.T Changes: ===================================== testsuite/tests/rename/should_fail/T26545.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE StaticPointers #-} + +module Foo where + +import GHC.Exts + +f :: Int# -> Int# +f 0# = 0# +f n# = f (n# -# 1#) + +h x = let v = f 3# in static (I# (v +# 1#)) ===================================== testsuite/tests/rename/should_fail/T26545.stderr ===================================== @@ -0,0 +1,3 @@ +T26545.hs:12:23: error: [GHC-88431] + ‘v’ is used in a static form but it is not defined at top level + ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -263,3 +263,4 @@ test('T25901_sub_b', normal, compile_fail, ['']) test('T25901_sub_c', [extra_files(['T25901_sub_c_helper.hs'])], multimod_compile_fail, ['T25901_sub_c', '-v0']) test('T25901_sub_d', [extra_files(['T25901_sub_d_helper.hs'])], multimod_compile_fail, ['T25901_sub_d', '-v0']) test('T25901_sub_w', normal, compile_fail, ['']) +test('T26545', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_compile/T24464.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE StaticPointers #-} +module T24464 where + +import GHC.StaticPtr + +class C a where + f :: a -> StaticPtr () + f _ = static () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -960,4 +960,5 @@ test('T26582', normal, compile, ['']) test('T26746', normal, compile, ['']) test('T26737', normal, compile, ['']) test('T26805a', normal, compile, ['']) +test('T24464', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_run/T16981.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE StaticPointers #-} +-- Main.hs +module Main where + +import GHC.StaticPtr + +class UniqueHash a where + hash :: a -> String + +{-# NOINLINE unCacheable #-} +unCacheable :: Cacheable a -> a +unCacheable (CExplicit _ a) = a + +data Cacheable a = CExplicit String a + +instance UniqueHash (StaticPtr a) where + hash ptr = show $ staticKey ptr + +instance IsStatic Cacheable where + fromStaticPtr ptr = CExplicit h a where + h = hash ptr + a = deRefStaticPtr ptr + +{-# NOINLINE splitInjectedAsWindowed #-} +splitInjectedAsWindowed :: Int +-- WindowedDataset +splitInjectedAsWindowed = unCacheable $ static 1 + + +main :: IO () +main = print splitInjectedAsWindowed ===================================== testsuite/tests/typecheck/should_run/T16981.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/typecheck/should_run/T24773.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE StaticPointers #-} +{-# OPTIONS_GHC -O1 #-} + +module Main where + +import GHC.StaticPtr ( StaticPtr ) + +{-# NOINLINE uhoh #-} +uhoh :: () -> StaticPtr () +uhoh = + let ptr :: StaticPtr () + ptr = static () + in \_ -> ptr + +main :: IO () +main = putStrLn "Hello, Haskell!" ===================================== testsuite/tests/typecheck/should_run/T24773.stdout ===================================== @@ -0,0 +1 @@ +Hello, Haskell! ===================================== testsuite/tests/typecheck/should_run/all.T ===================================== @@ -181,3 +181,5 @@ test('T15598', normal, compile_and_run, ['']) test('T22086', normal, compile_and_run, ['']) test('T24411', normal, compile_and_run, ['']) test('DefaultExceptionContext', normal, compile_and_run, ['']) +test('T24773', normal, compile_and_run, ['']) +test('T16981', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/530e8e580734b42740ae6d7145c999a5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/530e8e580734b42740ae6d7145c999a5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)