mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Odd behaviour with cons

Garklein opened this issue · comments

When I run the query

A=[a,a], A=[_|As], B=[b|As], write(B), length(B,L).

I get

[b]   A = "aa", As = "a", B = "ba", L = 3.

However, I expect it to output [b,a] instead of just [b], and for L to be 2.

In regard to the "[b]" case, I have "[b,a]".

My Scryer version is 2fdbb94 (compiled using: cargo build --release):

?- A=[a,a], A=[_|As], B=[b|As], write(B), length(B,L).
[b,a]   A = "aa", As = "a", B = "ba", L = 3, unexpected: L = 3.
% expected-but-not-found: [b,a]   A = "aa", As = "a", B = "ba", L = 2.

But "[b]" with a version 6417658:


?- A=[a,a], A=[_|As], B=[b|As], write(B), length(B,L).

[b]   A = "aa", As = "a", B = "ba", L = 3, unexpected.

Is this another issue with the current implementation of partial strings (#24), as we recently had with #2356?

It works as expected if we write it equivalently as:

?- A=[X,Y], X = a, Y = a, A=[_|As], B=[b|As], write(B), length(B,L).
[b,a]   A = "aa", X = a, Y = a, As = "a", B = "ba", L = 2.

I couldn't reproduce the incorrect [b] printing either but I did correct length(B,L).

Thank you!