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-07-10 17:32:00 +00:00
|
|
|
format pp_indent_expr(formatter const & fmt, expr const & e) {
|
|
|
|
return nest(get_pp_indent(fmt.get_options()), compose(line(), fmt(e)));
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
format pp_type_expected(formatter const & fmt, expr const & e) {
|
|
|
|
return compose(format("type expected at"), pp_indent_expr(fmt, e));
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
format pp_function_expected(formatter const & fmt, expr const & e) {
|
|
|
|
return compose(format("function expected at"), pp_indent_expr(fmt, e));
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
format pp_app_type_mismatch(formatter const & fmt, expr const & app, expr const & expected_type, expr const & given_type) {
|
2014-02-24 01:50:43 +00:00
|
|
|
format r;
|
|
|
|
r += format("type mismatch at application");
|
2014-07-10 17:32:00 +00:00
|
|
|
r += pp_indent_expr(fmt, app);
|
2014-05-12 21:49:42 +00:00
|
|
|
r += compose(line(), format("expected type:"));
|
2014-07-10 17:32:00 +00:00
|
|
|
r += pp_indent_expr(fmt, expected_type);
|
2014-05-12 21:49:42 +00:00
|
|
|
r += compose(line(), format("given type:"));
|
2014-07-10 17:32:00 +00:00
|
|
|
r += pp_indent_expr(fmt, given_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
format pp_def_type_mismatch(formatter const & fmt, name const & n, expr const & expected_type, expr const & given_type) {
|
2014-02-24 01:50:43 +00:00
|
|
|
format r("type mismatch at definition '");
|
|
|
|
r += format(n);
|
|
|
|
r += format("', expected type");
|
2014-07-10 17:32:00 +00:00
|
|
|
r += pp_indent_expr(fmt, expected_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
r += compose(line(), format("given type:"));
|
2014-07-10 17:32:00 +00:00
|
|
|
r += pp_indent_expr(fmt, given_type);
|
2014-02-24 01:50:43 +00:00
|
|
|
return r;
|
|
|
|
}
|
2014-06-25 15:51:33 +00:00
|
|
|
|
2014-07-19 20:15:32 +00:00
|
|
|
format pp_type_mismatch(formatter const & fmt, expr const & expected_type, expr const & given_type) {
|
|
|
|
format r("type mismatch, expected type");
|
|
|
|
r += ::lean::pp_indent_expr(fmt, expected_type);
|
|
|
|
r += compose(line(), format("given type:"));
|
|
|
|
r += ::lean::pp_indent_expr(fmt, given_type);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
format pp_decl_has_metavars(formatter const & fmt, name const & n, expr const & e, bool is_type) {
|
2014-06-25 15:51:33 +00:00
|
|
|
format r("failed to add declaration '");
|
|
|
|
r += format(n);
|
|
|
|
r += format("' to environment, ");
|
|
|
|
if (is_type)
|
|
|
|
r += format("type");
|
|
|
|
else
|
|
|
|
r += format("value");
|
|
|
|
r += format(" has metavariables");
|
2014-07-10 17:32:00 +00:00
|
|
|
r += pp_indent_expr(fmt, e);
|
2014-06-25 15:51:33 +00:00
|
|
|
return r;
|
|
|
|
}
|
2014-02-24 01:50:43 +00:00
|
|
|
}
|