Skip to content

Commit 5fbe15a

Browse files
committed
Better error contexts for internal type checking, and support CheckType of VectorSubref with non-literal heap parameters.
1 parent 837403d commit 5fbe15a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib/CheckType.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ instance (BindsNames b, CheckableB r b) => CheckableB r (WithExpl b) where
294294
checkB (WithExpl expl b) cont = checkB b \b' -> cont (WithExpl expl b')
295295

296296
typeCheckExpr :: (Typer m r, IRRep r) => EffectRow r o -> Expr r i -> m i o (Type r o)
297-
typeCheckExpr effs expr = case expr of
297+
typeCheckExpr effs expr = addContext ("Checking expr:\n" ++ pprint expr) case expr of
298298
App (EffTy _ reqTy) f xs -> do
299299
fTy <- getTypeE f
300300
checkApp effs fTy xs >>= checkAgainstGiven reqTy
@@ -607,11 +607,11 @@ typeCheckVectorOp = \case
607607
unless (sbt == sbt') $ throw TypeErr "Scalar type mismatch"
608608
return ty'
609609
VectorSubref ref i ty -> do
610-
RawRefTy (TabTy _ b (BaseTy (Scalar sbt))) <- getTypeE ref
610+
RefTy heap (TabTy _ b (BaseTy (Scalar sbt))) <- getTypeE ref
611611
i |: binderType b
612612
ty'@(BaseTy (Vector _ sbt')) <- checkTypeE TyKind ty
613613
unless (sbt == sbt') $ throw TypeErr "Scalar type mismatch"
614-
return $ RawRefTy ty'
614+
return $ RefTy heap ty'
615615

616616
typeCheckUserEffect :: Typer m CoreIR => UserEffectOp i -> m i o (CType o)
617617
typeCheckUserEffect = \case
@@ -687,7 +687,7 @@ typeCheckPrimHof effs hof = addContext ("Checking HOF:\n" ++ pprint hof) case ho
687687
makePreludeMaybeTy ty >>= checkAgainstGiven reqTy
688688

689689
typeCheckDAMOp :: forall r m i o . (Typer m r, IRRep r) => EffectRow r o -> DAMOp r i -> m i o (Type r o)
690-
typeCheckDAMOp effs op = addContext ("Checking DAMOp:\n" ++ show op) case op of
690+
typeCheckDAMOp effs op = addContext ("Checking DAMOp:\n" ++ pprint op) case op of
691691
Seq effAnn _ ixTy' carry f -> do
692692
effAnn' <- renameM effAnn
693693
checkExtends effs effAnn'

0 commit comments

Comments
 (0)