Commit 1766bb3c authored by mniip's avatar mniip Committed by Ben Gamari
Browse files

RtClosureInspect: Fix off-by-one error in cvReconstructType

Replaced error-prone index manipulation on a pointer array with
a simple fold on the array elements.

Test Plan: Added a test case that triggers the bug

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #12458
parent 89facad2
......@@ -898,10 +898,9 @@ cvReconstructType hsc_env max_depth old_ty hval = runTR_maybe hsc_env $ do
(_,mb_dc) <- tryTcErrs (tcLookupDataCon dcname)
case mb_dc of
Nothing-> do
-- TODO: Check this case
forM [0..length (elems $ ptrs clos)] $ \i -> do
tv <- newVar liftedTypeKind
return$ appArr (\e->(tv,e)) (ptrs clos) i
forM (elems $ ptrs clos) $ \a -> do
tv <- newVar liftedTypeKind
return (tv, a)
Just dc -> do
arg_tys <- getDataConArgTys dc my_ty
data D a = D
d = D
:print d
d `seq` ()
......@@ -86,3 +86,4 @@ test('T2740', normal, ghci_script, ['T2740.script'])
test('getargs', normal, ghci_script, ['getargs.script'])
test('T7386', normal, ghci_script, ['T7386.script'])
test('T8557', normal, ghci_script, ['T8557.script'])
test('T12458', normal, ghci_script, ['T12458.script'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment