match fails with a list of number #15

Closed
llibra opened this Issue Jun 19, 2011 · 5 comments

Comments

Projects
None yet
2 participants
@llibra

llibra commented Jun 19, 2011

It fails on specific cases.
Is it expected behavior?

(match '(0 1)
  ((_) t)
  (_ nil))
;=> NIL

(match '(0)
  ((0 1) t)
  (_ nil))
;>> Error: Can't match (NIL) with ((1)).

(match '(0 1)
  ((0) t)
  (_ nil))
;>> Error: Can't match ((1)) with (NIL).

(match '(0 1 2)
  ((0 1) t)
  (_ nil))
;>> Error: Can't match ((2)) with (NIL).
@llibra

This comment has been minimized.

Show comment Hide comment
@llibra

llibra Jun 19, 2011

Oops, it's my mistake.
It happens on other cases.

(match '(:a :b :c)
  ((:a :b) t)
  (_ nil))
;>> Error: Can't match ((C)) with (NIL).

llibra commented Jun 19, 2011

Oops, it's my mistake.
It happens on other cases.

(match '(:a :b :c)
  ((:a :b) t)
  (_ nil))
;>> Error: Can't match ((C)) with (NIL).
@llibra

This comment has been minimized.

Show comment Hide comment
@llibra

llibra Jun 21, 2011

Right? I don't have enough confidence.

--- compile.lisp        2011-04-26 17:21:07.000000000 +0900
+++ /home/llibra/work/compile.lisp      2011-06-22 08:34:09.106309499 +0900
@@ -51,7 +51,7 @@
                  for sub-clauses = (nreverse (cdr pair))
                  collect
                  `(,constant
-                    (%match ,(cdr vars) ,sub-clauses)))
+                    (%match ,(cdr vars) ,sub-clauses ,else)))
           ,else))))

 (defun compile-match-constructor (vars clauses else)

llibra commented Jun 21, 2011

Right? I don't have enough confidence.

--- compile.lisp        2011-04-26 17:21:07.000000000 +0900
+++ /home/llibra/work/compile.lisp      2011-06-22 08:34:09.106309499 +0900
@@ -51,7 +51,7 @@
                  for sub-clauses = (nreverse (cdr pair))
                  collect
                  `(,constant
-                    (%match ,(cdr vars) ,sub-clauses)))
+                    (%match ,(cdr vars) ,sub-clauses ,else)))
           ,else))))

 (defun compile-match-constructor (vars clauses else)
@fukamachi

This comment has been minimized.

Show comment Hide comment
@fukamachi

fukamachi Jun 22, 2011

Contributor

Matsuyama doesn't seem looking at this issue.
I am not familiar with cl-pattern, but I try to answer.

You are saying "It should return NIL instead of an error", right?

Contributor

fukamachi commented Jun 22, 2011

Matsuyama doesn't seem looking at this issue.
I am not familiar with cl-pattern, but I try to answer.

You are saying "It should return NIL instead of an error", right?

@fukamachi

This comment has been minimized.

Show comment Hide comment
@fukamachi

fukamachi Jun 22, 2011

Contributor

IMHO, you are right. And your patch doesn't break any unit tests.
It will be merged into this library soon.
Thank you for your contribution.

Contributor

fukamachi commented Jun 22, 2011

IMHO, you are right. And your patch doesn't break any unit tests.
It will be merged into this library soon.
Thank you for your contribution.

@fukamachi fukamachi closed this in a48a045 Jun 22, 2011

@llibra

This comment has been minimized.

Show comment Hide comment
@llibra

llibra Jun 22, 2011

Thank you for prompt replies. It works fine.

llibra commented Jun 22, 2011

Thank you for prompt replies. It works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment