mndrix/mavis

throw type error with reference to type declaration location

Opened this issue · 0 comments

Type errors are currently thrown from the point at which they're violated. This is useful because it shows the context in which the variable received an incorrect value. Unfortunately, there can be many type declarations in a program and it's also helpful to know which one was violated.

Consider the following code:

alpha(A) :-
    the(nonneg, A),
    beta(A).

beta(B) :-
    the(integer, B),
    gamma(B).

gamma(C) :-
    C = -9.

The type error exception originates in the first clause of gamma/1 but it violates a type declaration that was created in alpha/1.