@@ -636,7 +636,7 @@ elab ist info pattern opts fn tm
636636 elab' ina (PUnifyLog t) = do unifyLog True
637637 elab' ina t
638638 unifyLog False
639− elab' (ina, g, inty, qq) (PQuasiquote t)
639+ elab' (ina, g, inty, qq) (PQuasiquote t goal) -- TODO: goal type
640640 = do -- First extract the unquoted subterms, replacing them with fresh
641641 -- names in the quasiquoted term. Claim their reflections to be
642642 -- of type TT.
@@ -663,19 +663,25 @@ elab ist info pattern opts fn tm
663663 movelast n)
664664 unquoteNames
665665
666+ -- Determine whether there's an explicit goal type, and act accordingly
666667 -- Establish holes for the type and value of the term to be
667668 -- quasiquoted
668669 qTy <- getNameFrom (sMN 0 "qquoteTy")
669670 claim qTy RType
671+ movelast qTy
670672 qTm <- getNameFrom (sMN 0 "qquoteTm")
671673 claim qTm (Var qTy)
674+
672675 -- Let-bind the result of elaborating the contained term, so that
673676 -- the hole doesn't disappear
674677 nTm <- getNameFrom (sMN 0 "quotedTerm")
675678 letbind nTm (Var qTy) (Var qTm)
676− -- We must solve the type later through unification
677− movelast qTy
678679
680+ -- Fill out the goal type, if relevant
681+ case goal of
682+ Nothing -> return ()
683+ Just gTy -> do focus qTy
684+ elabE (ina, g, inty, True) gTy
679685
680686 -- Elaborate the quasiquoted term into the hole
681687 focus qTm