@@ -267,23 +267,23 @@ class BBTyper(using elState: Elaborator.State, tl: TL):
267267 case _ =>
268268 (error(msg " Cannot quote ${code.toString}" -> code.toLoc :: Nil ), Bot , Bot )
269269
270- private def typeFunDef (sym : Symbol , lam : Term , sig : Opt [Term ], pctx : BbCtx )(using ctx : BbCtx , cctx : CCtx , scope : Scope ) = lam match
270+ private def typeFunDef (sym : Symbol , lam : Term , sig : Opt [Term ])(using ctx : BbCtx , cctx : CCtx , scope : Scope ) = lam match
271271 case Term .Lam (params, body) => sig match
272272 case S (sig) =>
273273 val sigTy = typeType(sig)(using ctx)
274- pctx += sym -> sigTy
274+ ctx += sym -> sigTy
275275 ascribe(lam, sigTy)
276276 ()
277277 case N =>
278278 val outer = freshOuter(new TempSymbol (S (lam), " outer" ))(using ctx)
279279 given BbCtx = ctx.nestWithOuter(outer)
280280 val funTyV = freshVar(sym)
281- pctx += sym -> funTyV // for recursive functions
281+ ctx += sym -> funTyV // for recursive functions
282282 val (res, _) = typeCheck(lam)
283283 val funTy = tryMkMono(res, lam)
284284 given CCtx = CCtx .init(lam, N )
285285 constrain(funTy, funTyV)(using ctx)
286- pctx += sym -> PolyType .generalize(funTy, S (outer), 1 )
286+ ctx += sym -> PolyType .generalize(funTy, S (outer), ctx.lvl + 1 )
287287 case _ => error(msg " Function definition shape not yet supported for ${sym.nme}" -> lam.toLoc :: Nil )
288288
289289 private def typeSplit
@@ -443,10 +443,10 @@ class BBTyper(using elState: Elaborator.State, tl: TL):
443443 ctx += sym -> rhsTy
444444 goStats(stats)
445445 case (td @ TermDefinition (k = Fun , params = ps :: Nil , sign = sig, body = S (body))) :: stats =>
446- typeFunDef(td.sym, Term .Lam (ps, body), sig, ctx )
446+ typeFunDef(td.sym, Term .Lam (ps, body), sig)
447447 goStats(stats)
448448 case (td @ TermDefinition (k = Fun , params = Nil , sign = sig, body = S (body))) :: stats =>
449- typeFunDef(td.sym, body, sig, ctx ) // * may be a case expressions
449+ typeFunDef(td.sym, body, sig) // * may be a case expressions
450450 goStats(stats)
451451 case (td1 @ TermDefinition (k = Fun , sign = S (sig), body = None )) :: (td2 @ TermDefinition (k = Fun , body = S (body))) :: stats
452452 if td1.sym === td2.sym => goStats(td2 :: stats) // * avoid type check signatures twice
@@ -568,7 +568,7 @@ class BBTyper(using elState: Elaborator.State, tl: TL):
568568 constrain(tryMkMono(refTy, ref), BbCtx .refTy(ctnt, sk))
569569 (ctnt, sk | refEff)
570570 case Term .Quoted (body) =>
571- val nestCtx = ctx.nextLevel
571+ val nestCtx = ctx.nest
572572 given BbCtx = nestCtx
573573 val (ty, ctxTy, eff) = typeCode(body)
574574 (BbCtx .codeTy(ty, ctxTy), eff)
0 commit comments