2014-02-24 01:50:43 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "kernel/error_msgs.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2014-05-02 19:03:12 +00:00
|
|
|
format pp_indent_expr(formatter const & fmt, environment const & env, options const & opts, expr const & e) {
|
2014-04-30 17:28:07 +00:00
|
|
|
return nest(get_pp_indent(opts), compose(line(), fmt(env, e, opts)));
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 17:28:07 +00:00
|
|
|
format pp_type_expected(formatter const & fmt, environment const & env, options const & opts, expr const & e) {
|
|
|
|
return compose(format("type expected at"), pp_indent_expr(fmt, env, opts, e));
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 17:28:07 +00:00
|
|
|
format pp_function_expected(formatter const & fmt, environment const & env, options const & opts, expr const & e) {
|
|
|
|
return compose(format("function expected at"), pp_indent_expr(fmt, env, opts, e));
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 17:28:07 +00:00
|
|
|
format pp_app_type_mismatch(formatter const & fmt, environment const & env, options const & opts, expr const & app,
|
2014-02-24 01:50:43 +00:00
|
|
|
expr const & expected_type, expr const & given_type) {
|
|
|
|
format r;
|
|
|
|
r += format("type mismatch at application");
|
2014-04-30 17:28:07 +00:00
|
|
|
r += pp_indent_expr(fmt, env, opts, app);
|
2014-02-24 01:50:43 +00:00
|
|
|
r += format("expected type:");
|
2014-04-30 17:28:07 +00:00
|
|
|
r += pp_indent_expr(fmt, env, opts, expected_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
r += format("given type:");
|
2014-04-30 17:28:07 +00:00
|
|
|
r += pp_indent_expr(fmt, env, opts, given_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-04-30 17:28:07 +00:00
|
|
|
format pp_def_type_mismatch(formatter const & fmt, environment const & env, options const & opts, name const & n,
|
2014-02-24 01:50:43 +00:00
|
|
|
expr const & expected_type, expr const & given_type) {
|
|
|
|
format r("type mismatch at definition '");
|
|
|
|
r += format(n);
|
|
|
|
r += format("', expected type");
|
2014-04-30 17:28:07 +00:00
|
|
|
r += pp_indent_expr(fmt, env, opts, expected_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
r += compose(line(), format("given type:"));
|
2014-04-30 17:28:07 +00:00
|
|
|
r += pp_indent_expr(fmt, env, opts, given_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
return r;
|
|
|
|
}
|
2014-04-30 17:28:07 +00:00
|
|
|
format pp_def_lvl_cnstrs_satisfied(formatter const & fmt, environment const & env, options const & opts, expr const & e,
|
|
|
|
level const & lhs, level const & rhs) {
|
2014-04-25 17:46:17 +00:00
|
|
|
format r("constand definition level constraints are not satisfied");
|
2014-04-30 17:28:07 +00:00
|
|
|
r += pp_indent_expr(fmt, env, opts, e);
|
2014-04-25 17:46:17 +00:00
|
|
|
r += format("level constraint:");
|
|
|
|
r += pp(lhs, rhs, opts);
|
|
|
|
return r;
|
|
|
|
}
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|