Skip to content

Commit

Permalink
hack to fix alpha equivalence
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Ullrich committed Jan 20, 2023
1 parent a5748e7 commit 10f0cf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion thorin/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Def* infer_type_level(World& world, Defs defs) {
} else if (auto type = def->type()->isa<Type>()) {
level = std::max(level, as_lit(type->level()));
} else {
err(def->loc(), "'{}' used as a type but is in fact a term", def);
err(def->loc(), "'{}' : '{}' used as a type but is in fact a term", def, def->type());
}
}
return world.type(world.lit_univ(level));
Expand Down
14 changes: 14 additions & 0 deletions thorin/error.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "thorin/error.h"

#include <cstdio>

#include <sstream>

#include "thorin/lam.h"

#include "thorin/util/print.h"
Expand Down Expand Up @@ -28,6 +32,16 @@ void ErrorHandler::index_out_of_range(const Def* arity, nat_t index, const Def*

void ErrorHandler::ill_typed_app(const Def* callee, const Def* arg, const Def* dbg) {
Debug d(dbg ? dbg : arg->dbg());
// TODO: remove hack
// hack to at least accept cases that are syntactically equal
auto dom_type = callee->type()->as<Pi>()->dom();
auto arg_type = arg->type();
std::stringstream dom_type_str;
std::stringstream arg_type_str;
dom_type_str << dom_type;
arg_type_str << arg_type;
if (dom_type_str.str() == arg_type_str.str()) return;
// original error
err(d.loc, "cannot pass argument \n '{}' of type \n '{}' to \n '{}' of domain \n '{}'", arg, arg->type(),
callee, callee->type()->as<Pi>()->dom());
}
Expand Down

0 comments on commit 10f0cf2

Please sign in to comment.