May 29, 2020

duck-typing sh..

t:([] k:`a`b`a; v:1 2 3)
select k, v, kk:?[1=v mod 2; {`$a,a:string x} each k;k] from t
k  k1 v
-------
aa a  1
b  b  2
aa a  3

select k, v, kk:?[1=v mod 2; {`$a,a:string x} each k;k] from 0#t
'type
  [0]  select k, v, kk:?[1=v mod 2; {`$a,a:string x} each k;k] from 0#t

The root cause of the problem is quite simple:

type {x} each `a`b
11h
type {x} each `$()
0h // brakes everything, because ?[] check type of the second argument