I think this behavior is counterintuitive:
(poke) defvar a = [1, 2, 3]
(poke) defvar b = [1, 2]
(poke) defvar c = a[0:1]
(poke) b == c
<stdin>:1:6: error: invalid operand
<stdin>:1:6: error: expected int<32>, got int<32>
b == c;
Is this a design decision or just an implementation bug?
Thanks for the report.
This looks like a bug. The type of an array trim should be, generally, an unbounded array type having the same base type than the original array. So in:
defvar a = [1,2,3]
defvar b = a[0:1]
The type of `a' is int<32>
The type of `b' is int<32>
This is fixed in master with commit
commit 3cca7544d54eb7e45e0e1fc1a160bc0263391ced (HEAD -> master, origin/master, origin/HEAD)
Author: Jose E. Marchesi <firstname.lastname@example.org>
Date: Fri Aug 21 11:34:00 2020 +0200
typify: the types of trimmed arrays are unbounded
2020-08-21 Jose E. Marchesi <email@example.com>
* libpoke/pkl-typify.c (pkl_typify1_ps_trimmer): The type of a
trimmed array is unbounded.
* testsuite/poke.pkl/trim-26.pk: New test.