diff options
author | Teddy <[email protected]> | 2013-08-09 22:18:39 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-09 22:18:39 +0800 |
commit | 1985734990b5c5ab3fd50277bff854ea3cd92b2c (patch) | |
tree | d3e3843ef7b4779400addc1c53ebd8956a3f0995 | |
parent | 155c3e5d46909d36d9f595e2a3b8d786240b9520 (diff) |
fixed bug in `equal?`
-rw-r--r-- | builtin.cpp | 11 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | robust_test.scm | 3 |
3 files changed, 10 insertions, 6 deletions
diff --git a/builtin.cpp b/builtin.cpp index 98090e0..115377c 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1335,9 +1335,8 @@ do { \ int otype = (a = *l1)->get_otype(); if (otype != (b = *l2)->get_otype()) return new BoolObj(false); - if (a == empty_list) - continue; - if (otype & CLS_PAIR_OBJ) + if (a != empty_list && b != empty_list && + otype & CLS_PAIR_OBJ) { *r1 = TO_PAIR(a)->car; INC1(r1); @@ -1363,7 +1362,7 @@ do { \ it = va->vec.begin(); it != va->vec.end(); it++) { - *r1 = TO_PAIR(a)->car; + *r1 = *it; INC1(r1); CHK1; } @@ -1372,7 +1371,7 @@ do { \ it = vb->vec.begin(); it != vb->vec.end(); it++) { - *r2 = TO_PAIR(b)->car; + *r2 = *it; INC2(r2); CHK2; } @@ -1418,6 +1417,8 @@ do { \ static_cast<StrObj*>(b)->str) return new BoolObj(false); // (string=?) } + else if (a != b) + return new BoolObj(false); } return new BoolObj(true); } @@ -6,7 +6,7 @@ #include <cstdio> int main() { - //freopen("in.scm", "r", stdin); + freopen("in.scm", "r", stdin); Tokenizor *tk = new Tokenizor(); ASTGenerator *ast = new ASTGenerator(); Evaluator *eval = new Evaluator(); diff --git a/robust_test.scm b/robust_test.scm index 7b7bfd4..152e380 100644 --- a/robust_test.scm +++ b/robust_test.scm @@ -218,3 +218,6 @@ src (if #f 1 ()) ; Error ; "Test double quotes in comments" (display " Test double quotes outside the comments ; ;; ; ; ") + +(equal? #(1 2 '()) #(1 2 '(1))) +(equal? #(1 2 '(1)) #(1 2 '(1))) |