Swipl-wasm seems to lose last solution to a predicate

I’m using the latest version of swipl-wasm in a js project. I can load a prolog file, containing:

p(a).
p(b).
p(c).

into the prolog engine, then from the js side, I can query:

for (const a of swipl.prolog.query('p(X)')) {
  console.log(a.X);
}

and this returns, in the console:

a
b

It seems that the last solution isn’t reached (I tried also with other predicates). Can you reproduce this? Do you have any idea what this could be due to?

@jan for context

Interestingly,

console.log(prolog.query('findall(X, p(X), All)').once().All);

correctly prints:

Array(3) [ "a", "b", "c" ]

Thanks. There was a bug in the iterator implementation :frowning: Pushed a fix and updated SWI-Prolog WASM tests

1 Like

Thank you for the immediate fix @jan. Given that it is a fairly serious bug, could we hope in another release on npm of the swipl-wasm package soon?

@meditans, the npm package is maintained by @jeswr. You might have to submit a PR to change the commit hash here: npm-swipl-wasm/package.json at d00e479244240ab302d2055223f8f083499766d7 · SWI-Prolog/npm-swipl-wasm · GitHub

Thank you for the info @rla, it seems then that we have to wait for the commit to be released in the swipl repo (for now it’s in swipl-devel) as npm-swipl-wasm depends on that.

Actually, without particular hurry @jan, do you have any idea on when we could have a release of swi-prolog (that will be picked up by the npm package) containing this feature?

9.3.16 is being built right now. And, if I understood @jeswr correctly, the npm version was already updated to use the fixed non-release version.

1 Like

Thank you, I didn’t understand that the npm version was already out, but I see a new release now!