aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/repl.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/repl.cpp b/src/repl.cpp
index 204e2ab..50064f8 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -46,21 +46,9 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, const AST*& exp, const AS
Constraints c(cenv.tsubst);
resp_constrain(cenv.tenv, c, ast); // Constrain types
+ cenv.tsubst = unify(c);
- //cout << "(CONSTRAINTS " << endl << c << ")" << endl;
-
- const Subst subst = unify(c); // Solve type constraints
- for (Subst::const_iterator i = subst.begin(); i != subst.end(); ++i) {
- if (!cenv.tsubst.contains(i->first)) { // Substitution's LHS is a new variable
- cenv.tsubst.push_back(*i); // Add substitution to global type substitution
- Object::pool.addRoot(i->first);
- Object::pool.addRoot(i->second);
- }
- }
-
- //cout << "(SUBST " << endl << subst << ")" << endl;
//cout << "(TSUBST " << endl << cenv.tsubst << ")" << endl;
- cenv.tsubst = Subst::compose(cenv.tsubst, subst); // FIXME: breaks polymorphism + repl
Object::pool.addRoot(ast); // Make parsed expression a GC root so it is not deleted
@@ -70,6 +58,8 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, const AST*& exp, const AS
static void
callPrintCollect(CEnv& cenv, CFunc f, const AST* result, const AST* resultT, bool execute)
{
+ Object::pool.collect(Object::pool.roots());
+
if (execute)
cenv.out << cenv.engine()->call(cenv, f, resultT);