kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

Regression (Related to each??) #620

Closed gitonthescene closed 1 year ago

gitonthescene commented 2 years ago

I've been working through the Advent of Code using kona. I got day4.txt working on tio but it didn't work when I ran it at the command line.

The issue is that the following doesn't work in the current kona but does in the tio example linked above.

  bs:((0 0 1 1 1
  0 1 1 1 1
  1 1 1 0 1
  0 0 0 0 1
  0 0 0 0 0)
 (0 0 1 1 0
  1 0 0 1 1
  0 0 1 0 1
  0 1 0 1 1
  1 1 0 0 0)
 (1 1 1 1 1
  0 0 0 1 0
  0 0 1 0 0
  0 1 0 0 1
  1 1 0 0 1))
  b:bs 2
  b
(1 1 1 1 1
 0 0 0 1 0
 0 0 1 0 0
 0 1 0 0 1
 1 1 0 0 1)
  {|/(|/(&)/')'(x;+x)} b
1
  {|/(|/(&)/')'(x;+x)}'bs

The following workaround does in current kona:

  {|//{(|/(&)/')'(x;+x)}x}b
1
  {|//{(|/(&)/')'(x;+x)}x}'bs
0 0 1

[EDIT: I rand git bisect on this with the attached file (suffix changed)]

$ git bisect good; make; ./k day4.k
1f02a068912106f8f1f8cc14e0914aceb911877e is the first bad commit
commit 1f02a068912106f8f1f8cc14e0914aceb911877e
Author: Tom Szczesny <tom@new-host-2.home>
Date:   Wed May 15 16:19:57 2019 -0400

    pass dict by value

 src/kx.c |  2 +-
 src/kx.h |  2 +-
 src/p.c  | 26 +++++++++++++-------------
 src/p.h  |  4 ++--
 src/v.c  |  2 +-
 src/v.h  |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)
make: Nothing to be done for `all'.
kona      \ for help. \\ to exit.

  4512
1924
$

day4.k.txt

gitonthescene commented 2 years ago

Similarly, this works on tio but is not working on the command line.

I think this is where the problem is coming from:

  mks[t[0]@t[1];t[0]]
(2 2 2 2
 2 3 4 6
 2 2 4 4
 2 3 4 7
 1 2 3 5
 1 2 3 6
 2 3 3 6
 2 3 3 5
 2 3 2 3
 1 2 2 5
 1 2 3 5
 1 2 3 5
 2 2 2 2
 2 2 4 4)
  {mks[x[0]@x[1];x[0]]}t

I'm not sure what's happening here but it's not returning any results when I try to turn that statement into a function.

To be clear, I'm mentioning tio because I believe it has an old version of kona on it. The following workaround seems to work though.

 {mks@/(x[0]@x[1];x[0])}t
(2 2 2 2
 2 3 4 6
 2 2 4 4
 2 3 4 7
 1 2 3 5
 1 2 3 6
 2 3 3 6
 2 3 3 5
 2 3 2 3
 1 2 2 5
 1 2 3 5
 1 2 3 5
 2 2 2 2
 2 2 4 4)

Here is the input data: day8.txt

[EDIT: I ran git bisect on this as well with the attached script below (suffix changed. Note the k.txt here) and the attached input above.]

$ git bisect good; make; ./k day8.k
1f02a068912106f8f1f8cc14e0914aceb911877e is the first bad commit
commit 1f02a068912106f8f1f8cc14e0914aceb911877e
Author: Tom Szczesny <tom@new-host-2.home>
Date:   Wed May 15 16:19:57 2019 -0400

    pass dict by value

 src/kx.c |  2 +-
 src/kx.h |  2 +-
 src/p.c  | 26 +++++++++++++-------------
 src/p.h  |  4 ++--
 src/v.c  |  2 +-
 src/v.h  |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)
make: Nothing to be done for `all'.
kona      \ for help. \\ to exit.

  383
20998900
$

day8.k.txt

FWIW, the numbers still look wrong here, but at least it doesn't error. I'll try to debug where the numbers go wrong in the "working" version.

Also, when trying to run bisect I realized I didn't report the actual error above. I'm not sure if this is the same as when I reported it, but I'm now getting the following at HEAD. I get the same error for the example above as well.

$ /k day8.k
kona      \ for help. \\ to exit.

383
type error
{{z+y*x}/[0;x;y]}
   ^
>  
tavmem commented 1 year ago

I had similar results with this issue.

Using the "git checkout" for the commit of Jan 4, 2022 {|/(|/(&)/')'(x;+x)}'bs fails to produce output. However, using the current commit (of Aug 31, 2022)

$ rlwrap -n ./k
kona      \ for help. \\ to exit.

  bs:((0 0 1 1 1
>>    0 1 1 1 1
>>    1 1 1 0 1
>>    0 0 0 0 1
>>    0 0 0 0 0)
>   (0 0 1 1 0
>>    1 0 0 1 1
>>    0 0 1 0 1
>>    0 1 0 1 1
>>    1 1 0 0 0)
>   (1 1 1 1 1
>>    0 0 0 1 0
>>    0 0 1 0 0
>>    0 1 0 0 1
>>    1 1 0 0 1))

  b:bs 2

  b
(1 1 1 1 1
 0 0 0 1 0
 0 0 1 0 0
 0 1 0 0 1
 1 1 0 0 1)

  {|/(|/(&)/')'(x;+x)} b
1

  {|/(|/(&)/')'(x;+x)}'bs
0 0 1

I will close this issue. It can be reopened if I am missing something.