Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
d1d9e39e
by Ben Gamari at 2025-09-19T18:24:52-04:00
-
3eeecd50
by Ben Gamari at 2025-09-19T18:24:53-04:00
-
2e73f342
by sheaf at 2025-09-19T18:24:53-04:00
8 changed files:
- compiler/GHC/StgToByteCode.hs
- rts/Interpreter.c
- + testsuite/tests/bytecode/T26216.hs
- + testsuite/tests/bytecode/T26216.script
- + testsuite/tests/bytecode/T26216.stdout
- + testsuite/tests/bytecode/T26216_aux.hs
- testsuite/tests/bytecode/all.T
- testsuite/tests/codeGen/should_run/T23146/all.T
Changes:
| ... | ... | @@ -2331,11 +2331,12 @@ pushAtom d p (StgVarArg var) |
| 2331 | 2331 | -- PUSH_G doesn't tag constructors. So we use PACK here
|
| 2332 | 2332 | -- if we are dealing with nullary constructor.
|
| 2333 | 2333 | case isDataConWorkId_maybe var of
|
| 2334 | - Just con -> do
|
|
| 2335 | - massert (isNullaryRepDataCon con)
|
|
| 2336 | - return (unitOL (PACK con 0), szb)
|
|
| 2334 | + Just con
|
|
| 2335 | + -- See Note [LFInfo of DataCon workers and wrappers] in GHC.Types.Id.Make.
|
|
| 2336 | + | isNullaryRepDataCon con ->
|
|
| 2337 | + return (unitOL (PACK con 0), szb)
|
|
| 2337 | 2338 | |
| 2338 | - Nothing
|
|
| 2339 | + _
|
|
| 2339 | 2340 | -- see Note [Generating code for top-level string literal bindings]
|
| 2340 | 2341 | | idType var `eqType` addrPrimTy ->
|
| 2341 | 2342 | return (unitOL (PUSH_ADDR (getName var)), szb)
|
| ... | ... | @@ -2227,7 +2227,6 @@ run_BCO: |
| 2227 | 2227 | // n_nptrs=1, n_ptrs=0.
|
| 2228 | 2228 | ASSERT(n_ptrs + n_nptrs == n_words || (n_nptrs == 1 && n_ptrs == 0));
|
| 2229 | 2229 | ASSERT(n_ptrs + n_nptrs > 0);
|
| 2230 | - //ASSERT(n_words > 0); // We shouldn't ever need to allocate nullary constructors
|
|
| 2231 | 2230 | for (W_ i = 0; i < n_words; i++) {
|
| 2232 | 2231 | con->payload[i] = (StgClosure*)ReadSpW(i);
|
| 2233 | 2232 | }
|
| 1 | +{-# LANGUAGE GHC2024, BlockArguments, MagicHash #-}
|
|
| 2 | + |
|
| 3 | +module T26216 (main) where
|
|
| 4 | + |
|
| 5 | +import Data.Kind (Type, Constraint)
|
|
| 6 | +import GHC.TypeNats
|
|
| 7 | +import GHC.Exts (proxy#)
|
|
| 8 | + |
|
| 9 | +import T26216_aux
|
|
| 10 | + |
|
| 11 | +getN :: forall (n :: Nat). SNat n -> Natural
|
|
| 12 | +getN s = withKnownNat s (natVal s)
|
|
| 13 | + |
|
| 14 | +type C :: forall {k}. (k -> Constraint) -> k -> Type
|
|
| 15 | +data C c a where { C :: c a => C c a }
|
|
| 16 | + |
|
| 17 | +know :: forall (n :: Nat). SNat n -> C KnownNat n
|
|
| 18 | +know s = withKnownNat s C
|
|
| 19 | + |
|
| 20 | +getC :: forall (n :: Nat). C KnownNat n -> Natural
|
|
| 21 | +getC C = natVal' (proxy# @n)
|
|
| 22 | + |
|
| 23 | +main :: IO ()
|
|
| 24 | +main = do
|
|
| 25 | + let !s = mkSome $ natSing @42
|
|
| 26 | + !c = withSome s $ mkSome . know
|
|
| 27 | + print $ withSome s getN
|
|
| 28 | + print $ withSome c getC |
| 1 | +:l T26216
|
|
| 2 | +main |
| 1 | +42
|
|
| 2 | +42 |
| 1 | +{-# LANGUAGE GHC2024 #-}
|
|
| 2 | +{-# LANGUAGE PatternSynonyms #-}
|
|
| 3 | +{-# LANGUAGE PolyKinds #-}
|
|
| 4 | + |
|
| 5 | +module T26216_aux (Some, data Some, mkSome, withSome) where
|
|
| 6 | +import Data.Kind (Type)
|
|
| 7 | +import GHC.Exts (Any)
|
|
| 8 | +import Unsafe.Coerce (unsafeCoerce)
|
|
| 9 | + |
|
| 10 | +type Some :: (k -> Type) -> Type
|
|
| 11 | +newtype Some tag = UnsafeSome (tag Any)
|
|
| 12 | +type role Some representational
|
|
| 13 | + |
|
| 14 | +{-# COMPLETE Some #-}
|
|
| 15 | +pattern Some :: tag a -> Some tag
|
|
| 16 | +pattern Some x <- UnsafeSome x
|
|
| 17 | + where Some x = UnsafeSome ((unsafeCoerce :: tag a -> tag Any) x)
|
|
| 18 | + |
|
| 19 | +-- | Constructor.
|
|
| 20 | +mkSome :: tag a -> Some tag
|
|
| 21 | +mkSome = \x -> UnsafeSome (unsafeCoerce x)
|
|
| 22 | + |
|
| 23 | +-- | Eliminator.
|
|
| 24 | +withSome :: Some tag -> (forall a. tag a -> b) -> b
|
|
| 25 | +withSome (UnsafeSome thing) some = some (unsafeCoerce thing) |
| ... | ... | @@ -5,3 +5,7 @@ test('T23068', ghci_dump_bcos + [filter_stdout_lines(r'.*bitmap: .*')], ghci_scr |
| 5 | 5 | test('T25975', extra_ways(ghci_ways), compile_and_run,
|
| 6 | 6 | # Some of the examples work more robustly with these flags
|
| 7 | 7 | ['-fno-break-points -fno-full-laziness'])
|
| 8 | + |
|
| 9 | +# Nullary data constructors
|
|
| 10 | +test('T26216', extra_files(["T26216_aux.hs"]), ghci_script, ['T26216.script'])
|
|
| 11 | + |
| 1 | 1 | test('T23146', normal, compile_and_run, [''])
|
| 2 | 2 | test('T23146_lifted', normal, compile_and_run, [''])
|
| 3 | -test('T23146_liftedeq', expect_broken_for(23060, ghci_ways), compile_and_run, [''])
|
|
| 3 | +test('T23146_liftedeq', normal, compile_and_run, [''])
|
|
| 4 | 4 | test('T23146_lifted_unlifted', normal, compile_and_run, ['']) |