guicho271828 / trivia

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

Error message for illegal lambda lists is not useful #138

Open mathrick opened 2 years ago

mathrick commented 2 years ago

For example:

(match '(foo :operator or) 
           ((lambda-list &rest rest &optional asd)))

=>
Pattern: (((LIST* '&AUX TRIVIA.LEVEL2.IMPL::ARGV)
           (MULTIPLE-VALUE-BIND (TRIVIA.LEVEL2.IMPL::ARGV REST)
               (TRIVIA.LEVEL2.IMPL::TAKE-WHILE
                TRIVIA.LEVEL2.IMPL::ARGV
                #'TRIVIA.LEVEL2.IMPL::!LAMBDA-LIST-KEYWORD-P)
             (WHEN TRIVIA.LEVEL2.IMPL::ARGV
               (PUSH
                `(:AUX
                  ,@(MAPCAR #'ALEXANDRIA:ENSURE-LIST
                            TRIVIA.LEVEL2.IMPL::ARGV))
                TRIVIA.LEVEL2.IMPL::RESULTS))
             (EMATCH REST
               #1=(NIL))))
          #1#) 
 Values: ((&OPTIONAL ASD))
   [Condition of type MATCH-ERROR]

Versus SBCL's error when using DESTRUCTURING-BIND:

(destructuring-bind (&rest rest &optional asd) '(foo :operator or))

=>
misplaced &OPTIONAL in lambda list: (&REST REST &OPTIONAL ASD)
   [Condition of type SB-INT:SIMPLE-PROGRAM-ERROR]

The same applies to &REST:

(match '(foo :operator or)
           ((lambda-list name &key operator &rest rest)))
;; versus
(destructuring-bind (name &key operator &rest rest) '(foo :operator or))