matsud224 / wamcompiler

Prolog implementation based on Warren's abstract machine
The Unlicense
41 stars 6 forks source link

Hunting bugs #2

Closed FemtoEmacs closed 4 years ago

FemtoEmacs commented 4 years ago

I tried to create simple instances of the bug I found in wamcompiler. In fact, I can reproduce the bugs from the repl. Besides, I found another bug in the repl itself.

Bug 1 -- This is quite easy to fix, I believe.

~/wambugs/wamcompiler master •
› rlwrap ros run
* (load "wamcompiler.lisp")
* (repl)
> ?- !, write(passed), nl.

debugger invoked on a TYPE-ERROR in thread
#<THREAD "main thread" RUNNING {10005184C3}>:
  The value
    NIL
  is not of type
    NUMBER
  when binding SB-KERNEL::X

To fix this bug, I believe that one should go to the send-query definition and fix the neck-cut snippet as shown below:

       (neck-cut (when  (and *B* *B0* (addr< *B0* *B*))
                   (setq *B* *B0*)
                   (tidy-trail))
                 (setq *P* (cdr *P*))) 

Bug 2 -- This one is tough for a person who is not familiar with the wam. By the way, I think that you had it right, since you added the definition of the takai predicate into prelude.pl. Since the takai predicate does not work because of this bug, I believe that wamcompiler was correct when you tested the prelude. Any way, here is a simple test for bug 2:

* (repl)
> ?- X is 42, X < 50, write(passed), nl.
passed
X = 42

yes.
> ?- X is 42, X < 50, !, write(passed), nl.
matsud224 commented 4 years ago

The bug of cut reported in #4 was fixed, but Bug 2 is still remains...

matsud224 commented 4 years ago

The bug 2 described above seems to be fixed by commit 089711a. Thank you for finding bugs!