Serialize constraints in types (literal arguments still not supported)
This involved, in part, changing the ast::def type so that a def_fn has a "purity" field. This lets the typechecker determine whether functions defined in other crates are pure. It also required updating some error messages in tests. As a test for cross-crate constrained functions, I added a safe_slice function to std::str (slice(), with one of the asserts replaced with a function precondition) and some test cases (various versions of fn-constraint.rs) that call it. Also, I changed "fn" to "pred" for some of the boolean functions in std::uint.
This commit is contained in:
parent
3b6d94d489
commit
7fb35ecf84
15 changed files with 147 additions and 113 deletions
|
|
@ -412,7 +412,7 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
|
|||
lookup_path_strict(*e, sc, c.span, c.node.path.node.idents, ns_value);
|
||||
if (option::is_some(new_def)) {
|
||||
alt (option::get(new_def)) {
|
||||
case (ast::def_fn(?pred_id)) {
|
||||
case (ast::def_fn(?pred_id, _)) {
|
||||
let ty::constr_general[uint] c_ =
|
||||
rec(path=c.node.path, args=c.node.args, id=pred_id);
|
||||
let ty::constr_def new_constr = respan(c.span, c_);
|
||||
|
|
@ -799,9 +799,9 @@ fn found_def_item(&@ast::item i, namespace ns) -> option::t[def] {
|
|||
ret some(ast::def_const(local_def(i.id)));
|
||||
}
|
||||
}
|
||||
case (ast::item_fn(_, _)) {
|
||||
case (ast::item_fn(?f, _)) {
|
||||
if (ns == ns_value) {
|
||||
ret some(ast::def_fn(local_def(i.id)));
|
||||
ret some(ast::def_fn(local_def(i.id), f.decl.purity));
|
||||
}
|
||||
}
|
||||
case (ast::item_mod(_)) {
|
||||
|
|
@ -1122,7 +1122,7 @@ fn index_nmod(&ast::native_mod md) -> mod_index {
|
|||
// External lookups
|
||||
fn ns_for_def(def d) -> namespace {
|
||||
ret alt (d) {
|
||||
case (ast::def_fn(?id)) { ns_value }
|
||||
case (ast::def_fn(?id, _)) { ns_value }
|
||||
case (ast::def_obj(?id)) { ns_value }
|
||||
case (ast::def_obj_field(?id)) { ns_value }
|
||||
case (ast::def_mod(?id)) { ns_module }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue