guicho271828 / trivia

Pattern Matcher Compatible with Optima
Other
334 stars 22 forks source link

Fix type inference in EQ, EQL, EQUAL and EQUALP patterns. #93

Closed marcoheisig closed 5 years ago

marcoheisig commented 5 years ago

Currently, a pattern like (trivia:lambda-match ('foo 42)) will erroneously add a type declaration of (eql 'foo) to the variable that matches 'foo. The correct declaration would be (eql foo). Currently, the automatically generated type declarations for EQ, EQL, EQUAL and EQUALP are wrong for everything but self evaluating objects.

This problem manifests itself when optimizing a pattern like (trivia:lambda-match ((or 'x 'x) 42)) with the balland2006 optimizer. Here, SBCL will emit the following warning:

; Derived type of #:fusion5 is ; (values (member x) &optional), ; conflicting with its asserted type ; (values (member (quote x)) &optional).

I attached a potential fix.

PS: Thank you for providing this amazing library!

guicho271828 commented 5 years ago

Thanks for pointing it out. The issue is valid. Ill merge the fix after work, but your fix still has some problems so I'll append some commits after it.