brownplt / ZZZ-captain-teach

Set sail for Learning Island! Deprecated and no longer maintained
5 stars 1 forks source link

Type-checking in the Interactions Window #20

Open vhsiao opened 11 years ago

vhsiao commented 11 years ago

Type checking hasn't been implemented in the interactions window. For example:

 > x :: Number = "nonNumber"
nothing

A type error should have been raised.

elfprince13 commented 10 years ago

It's important to note that this isn't just a convenience issue as far as making it easier for certain classes of bugs to slip through. It actually makes it so that perfectly valid Pyret programs can't even execute within Captain Teach.

Here's example code from this discussion on the mailing list.

fun even(n :: Number):
    try:
        safenum :: Number(fun (n): n.modulo(2) == 0 end) = n
        true
    except (e):
        cases(error.Error) e:
        | user-contract-failure(msg, location, trace) => false
        end
    end
where:
    even(2) is true
    even(3) is false
end