Open vsbogd opened 7 months ago
Not that straightforward because in the following example:
(: a T)
(: foo (-> T T))
(= (foo $x) $x)
(= (bar $x) $x)
!(foo (bar a))
bar
has no type and (bar a)
interpreted as a tuple. As a consequence the type of (bar a)
is (%Undefined% T)
which is not unified with T
required by foo
. Thus relaxed type-checking allows using untyped functions in many examples.
For example recursive fact
definition also fails with tuple type-checking enabled:
(= (fact $n) (if (== $n 0) 1 (* (fact (- $n 1)) $n)))
!(assertEqual (fact 5) 120)
We could check alternative interpretations:
Describe the bug
Type checking doesn't work for tuples.
To Reproduce
Run the following MeTTa code:
Expected behavior
Type error:
(Error (a b) BadType)
Actual behavior
No type error:
succ