Test that fn preconditions get typechecked
This commit is contained in:
18
src/test/compile-fail/nonsense-constraints.rs
Normal file
18
src/test/compile-fail/nonsense-constraints.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Tests that the typechecker checks constraints
|
||||||
|
// error-pattern:mismatched types: expected uint but found u8
|
||||||
|
use std;
|
||||||
|
import std::uint;
|
||||||
|
|
||||||
|
fn enum_chars(start:u8, end:u8) : uint::le(start, end) -> [char] {
|
||||||
|
let i = start;
|
||||||
|
let r = [];
|
||||||
|
while (i <= end) {
|
||||||
|
r += [i as char];
|
||||||
|
i += (1u as u8);
|
||||||
|
}
|
||||||
|
ret r;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
log (enum_chars('a' as u8, 'z' as u8));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user