Potential bug with Fold + Reflex

24 views
Skip to first unread message

LdBeth

unread,
Feb 22, 2026, 4:40:49 AM (12 days ago) Feb 22
to fo...@jsoftware.com
For a prime sieve function:

naiveSieve=:{{ s ]F.:((-.+:+]*}:@:i.@(y&(<.@%)))~^:e.) s=.}.>:i.y }}

naiveSieve 6 NB. primes lesser equal to 6
2 3 5

I try to rewrite with Reflex adverb, but it gives wrong result:

naiveSieve1=:{{ (]F.:((-.+:+]*}:@:i.@(y&(<.@%)))~^:e.))~}.>:i.y }}

naiveSieve1 6
4 5

JVERSION
Engine: j9.7.0-beta12/j64arm/darwin
Build: commercial/2026-02-14T02:07:47/clang-17-0-0/SLEEF=1
Library: 9.7.8
Platform: Darwin 64
Installer: j9.7 install
InstallPath: /usr/local/lib/j9.7
Contact: www.jsoftware.com

LdBeth

unread,
Feb 22, 2026, 11:43:37 PM (11 days ago) Feb 22
to fo...@jsoftware.com
tried on various platforms,

on the J Server it also gives wrong result:

Engine: j9.7.0-beta8/j32/wasm
Build: commercial/2025-10-05T19:11:34/clang-22-0-0/SLEEF=0
Library: 9.7.4
Platform: Wasm 32
Installer: unknown
InstallPath: /home/web_user/j
Contact: www.jsoftware.com

{{ (]F.:((-.+:+]*}:@:i.@(y&(<.@%)))~^:e.))~}.>:i.y }} 6
4 5

on the Juno, however, the same expression gives expected result

Engine: j9.7.0-beta8/j32/wasm
Build: commercial/2025-10-05T19:11:34/clang-22-0-0/SLEEF=0
Library: 9.7.4
Platform: Wasm 32
Installer: unknown
InstallPath: /home/web_user/j
Contact: www.jsoftware.com

{{ (]F.:((-.+:+]*}:@:i.@(y&(<.@%)))~^:e.))~}.>:i.y }} 6
[1]: 2 3 5

LdBeth

unread,
Feb 22, 2026, 11:45:46 PM (11 days ago) Feb 22
to fo...@jsoftware.com
>>>>> In <tencent_DDB3EE5E47C31E...@qq.com>
>>>>> LdBeth <and...@foxmail.com> wrote:
> tried on various platforms,

> on the J Server it also gives wrong result:

> Engine: j9.7.0-beta8/j32/wasm
> Build: commercial/2025-10-05T19:11:34/clang-22-0-0/SLEEF=0
> Library: 9.7.4
> Platform: Wasm 32
> Installer: unknown
> InstallPath: /home/web_user/j
> Contact: www.jsoftware.com

Apologies, the JVERSION on the Sever should be:

Engine: j9.6.2/j64avx2/linux
Build: commercial/2025-03-07T01:32:02/clang-11-0-0/SLEEF=1
Library: 9.6.12
Platform: Linux 64
Installer: j9.6 install
InstallPath: /jguest/j
Contact: www.jsoftware.com

Henry Rich

unread,
Feb 23, 2026, 1:41:16 AM (11 days ago) Feb 23
to forum
I have found the bug and am working on a fix. 

Henry Rich

To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Henry Rich

unread,
Feb 23, 2026, 2:27:12 AM (11 days ago) Feb 23
to forum
Fixed for next beta. Fold single could prematurely free a block, with bad results if the block was in use elsewhere in the sentence (as in this case, where it was the other argument to the fold).
Workaround: assign the argument to the fold to a name before calling the fold. 

Thanks for the clear report. 

Henry Rich
Reply all
Reply to author
Forward
0 new messages