By removing the default switch case I get the following warning: term.c:566:17: warning: enumeration value ‘TERM_TYPE_INDEX_FUNCTION’ not handled in switch [-Wswitch] that likely means we are not handling comparisons with funs.
TERM_TYPE_INDEX_FUNCTION must be handled in term_compare() implementation in term.c.
Also fun comparison must be added to our tests.