@@ -1928,11 +1928,15 @@ runElabAction ist fc env tm ns = do tm' <- eval tm
19281928 = do solve
19291929 returnUnit
19301930 | n == tacN "prim__Goal", [] <- args
1931− = do (h:_) <- get_holes
1932− t <- goal
1933− fmap fst . checkClosed $
1934− rawPair (Var (reflm "TTName"), Var (reflm "TT"))
1935− (reflectName h, reflect t)
1931+ = do hs <- get_holes
1932+ case hs of
1933+ (h : _) -> do t <- goal
1934+ fmap fst . checkClosed $
1935+ rawPair (Var (reflm "TTName"), Var (reflm "TT"))
1936+ (reflectName h, reflect t)
1937+ [] -> lift . tfail . Msg $
1938+ "Elaboration is complete. There are no goals."
1939+
19361940 | n == tacN "prim__Holes", [] <- args
19371941 = do hs <- get_holes
19381942 fmap fst . checkClosed $
@@ -2153,10 +2157,14 @@ runElabAction ist fc env tm ns = do tm' <- eval tm
21532157 datatypes <- get_datatypes
21542158 env <- get_env
21552159 (_, ES (p, aux') _ _) <-
2156− lift $ runElab aux (runElabAction ist fc [] script ns)
2157− (newProof recH ctxt datatypes goalTT)
2160+ do (ES (current_p, _) _ _) <- get
2161+ lift $ runElab aux (runElabAction ist fc [] script ns)
2162+ ((newProof recH ctxt datatypes goalTT)
2163+ { nextname = nextname current_p})
21582164 let tm_out = getProofTerm (pterm p)
2159− updateAux $ const aux'
2165+ do (ES (prf, _) s e) <- get
2166+ let p' = prf { nextname = nextname p }
2167+ put (ES (p', aux') s e)
21602168 env' <- get_env
21612169 (tm, ty, _) <- lift $ recheck ctxt env (forget tm_out) tm_out
21622170 let (tm', ty') = (reflect tm, reflect ty)