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:
Tim Chevalier 2011-06-20 17:29:54 -07:00
parent 3b6d94d489
commit 7fb35ecf84
15 changed files with 147 additions and 113 deletions

View file

@ -10,17 +10,17 @@ fn div(uint x, uint y) -> uint { ret x / y; }
fn rem(uint x, uint y) -> uint { ret x % y; }
fn lt(uint x, uint y) -> bool { ret x < y; }
pred lt(uint x, uint y) -> bool { ret x < y; }
fn le(uint x, uint y) -> bool { ret x <= y; }
pred le(uint x, uint y) -> bool { ret x <= y; }
fn eq(uint x, uint y) -> bool { ret x == y; }
pred eq(uint x, uint y) -> bool { ret x == y; }
fn ne(uint x, uint y) -> bool { ret x != y; }
pred ne(uint x, uint y) -> bool { ret x != y; }
fn ge(uint x, uint y) -> bool { ret x >= y; }
pred ge(uint x, uint y) -> bool { ret x >= y; }
fn gt(uint x, uint y) -> bool { ret x > y; }
pred gt(uint x, uint y) -> bool { ret x > y; }
fn max(uint x, uint y) -> uint { if (x > y) { ret x; } ret y; }