This seems like type-checking gone wrong:
> has_value(({ "a", "b", "c" }), "d"); Compiler Error: 1: Bad argument 2 to has_value. Compiler Error: 1: Expected: string(97..99). Compiler Error: 1: Got : string(100..100).
And it is not just an artifact of Hilfe. Attempting to run this program:
void main() { write("%d\n", has_value(({ "a", "b", "c" }), "d")); }
Gives this error message:
/home/ceder/pike-fun/has-value.pike:3:Bad argument 2 to has_value. /home/ceder/pike-fun/has-value.pike:3:Expected: string(97..99). /home/ceder/pike-fun/has-value.pike:3:Got : string(100..100). Pike: Failed to compile script.
If I store the array and the string in variables, everything works fine.
What I really wanted to do was to read the documentation of has_value(), as I always forget if the haystack is the first or the second argument. And my browser was unresponsive, so I decided to just test it manually. Perhaps I should have used
> doc has_value
instead, but that seems broken too:
Pike v8.0 release 807 running Hilfe v3.5 (Incremental Pike Frontend) > doc has_value Illegal comment "/*! @decl object _static_modules\n" " *!\n" " *! This is an object containing the classes for all static\n" " *! (ie non-dynamic) C-modules.\n" " *!\n" " *! In a typic Pike with support for dynamic modules the contained\n" " *! module classes are:\n" " *! @dl\n" " *! @item @[Builtin]\n" " *! @item @[Gmp]\n" " *! @item @[_Stdio]\n" " *! @item @[_math]\n" " *! @item @[_system]\n" " *! @enddl\n" " *!\n" " *! If the Pike binary lacks support for dynamic modules, all C-modules\n" " *! will show up here.\n" " */" in "_static_modules.Builtin".
scope(0,function(object, mixed : int(1bit)) | function(string, int | string : int(1bit)) | function(array((0=mixed)), 0 : int(1bit)) | function(multiset, int : int(1bit)) | function(mapping(mixed:(1=mixed)), 1 : int(1bit)))
This is from a freshly compiled Pike from the 8.0 branch, made with "make -j12 tinstall".
The has_value issue also exists on the 8.1 branch, but "doc has_value" is slightly better there:
> doc has_value
scope(0,function(object, mixed : int(1bit)) | function(string, int | string : int(1bit)) | function(array((0=mixed)), 0 : int(1bit)) | function(multiset, int : int(1bit)) | function(mapping(mixed:(1=mixed)), 1 : int(1bit)))
While not very readable, I guess it contains the info I needed. :-)