jsoftware / jsource

J engine source mirror
Other
645 stars 91 forks source link

dbsig ignores x argument when is called from obverse #193

Open jip opened 2 months ago

jip commented 2 months ago

Test script in ~temp/dbsig_bug.ijs:

f=: 3 : 0
  'custom error in f' 13!:8^:((0 e. ])`(12"_)) y
  'result of f'
)

g=: 3 : 0
  ' and g' ,~ f y
)

h=: (3 : 0) :. (3 : 0)
  ' and h^:_1' ,~ f y
)
  ' and h' ,~ f y
)

Demonstration:

   load '~temp/dbsig_bug.ijs'
   f 1
result of f
   f 0
|custom error in f: f
|   'custom error in f'    13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');_))y
   g 1
result of f and g
   g 0
|custom error in f: f
|   'custom error in f'    13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');_))y
   h 1
result of f and h
   h 0
|custom error in f: f
|   'custom error in f'    13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');_))y
   h^:_1 (1)
result of f and h^:_1
   h^:_1 (0)
|assertion failure
|the result was expected to be all 1
|       h^:_1(0)

So, dbsig ignores x argument when is called from obverse, as the last assertion failure demonstrates.

Version strings:

   JVERSION
Engine: j9.6.0-beta5/j64/linux
Build: commercial/2024-04-11T16:59:56/clang-11-0-0/SLEEF=1
Library: 9.6.5
Platform: Linux 64
Installer: j9.6 install
InstallPath: /home/user/j9.6.0-beta5_j64
Contact: www.jsoftware.com

   JVERSION
Engine: j9.5.1/j64/linux
Build: commercial/2023-12-20T04:06:17/clang-11-0-0/SLEEF=1
Library: 9.5.5
Platform: Linux 64
Installer: j9.5 install
InstallPath: /home/user/j9.5.1_j64
Contact: www.jsoftware.com
`
HenryHRich commented 2 months ago

I am on my phone and unable to reproduce the details. But know that most inverses are inverses of the monad. Does that explain what you see?

hhr

On Thu, Apr 18, 2024, 11:36 PM Igor Zhuravlov @.***> wrote:

Test script in ~temp/dbsig_bug.ijs:

f=: 3 : 0 'custom error in f' 13!:8^:((0 e. ])`(12"_)) y 'result of f' )

g=: (3 : 0) :. (3 : 0) ' and g^:_1' ,~ f y ) ' and g' ,~ f y )

h=: 3 : 0 ' and h' ,~ f y )

Demonstration:

load '~temp/dbsigbug.ijs' f 1 result of f f 0 1|custom error in f: f| 'custom error in f' 13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');))y h 1 result of f and h h 0 1|custom error in f: f| 'custom error in f' 13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');))y g 1 result of f and g g 0 1|custom error in f: f| 'custom error in f' 13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');))y g^:_1 (1) result of f and g^:_1 g^:_1 (0 1)|assertion failure|the result was expected to be all 1| g^:_1(0 1)

So, dbsig ignores x argument when is called from obverse, as the last assertion failure demonstrates.

Version strings:

JVERSION Engine: j9.6.0-beta5/j64/linux Build: commercial/2024-04-11T16:59:56/clang-11-0-0/SLEEF=1 Library: 9.6.5 Platform: Linux 64 Installer: j9.6 install InstallPath: /home/user/j9.6.0-beta5_j64 Contact: www.jsoftware.com

JVERSION Engine: j9.5.1/j64/linux Build: commercial/2023-12-20T04:06:17/clang-11-0-0/SLEEF=1 Library: 9.5.5 Platform: Linux 64 Installer: j9.5 install InstallPath: /home/user/j9.5.1_j64 Contact: www.jsoftware.com`

— Reply to this email directly, view it on GitHub https://github.com/jsoftware/jsource/issues/193, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKVAJ4KGKF4MJZ6FXBVLELY6CGMPAVCNFSM6AAAAABGONKHEGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2TEMBQHE2TKOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jip commented 2 months ago

I guess no: f, g and h verbs in my demo are monads. When dbsig is called from monadic obverse, it ignores x argument supplied to dbsig. And it uses it when called from direct monadic invocation.

I've just found a simpler demo:

h=: (3 : 0) :. (3 : 0)
  'custom error in h^:_1' 13!:8^:((0 e. ])`(12"_)) y
  'result of h^:_1'
)
  'custom error in h' 13!:8^:((0 e. ])`(12"_)) y
  'result of h'
)

Demo:

   h 1
result of h
   h 0
|custom error in h: h
|   'custom error in h'    13!:8^:(((<(<,'3'),<(<(,'0');0),(<'e.'),<,']'),<(<,'"'),<(<(,'0');12),<(,'0');_))y
Press ENTER to inspect
   h^:_1 (1)
result of h^:_1
   h^:_1 (0)
|assertion failure
|the result was expected to be all 1
|       h^:_1(0)