It's very related to this:
| > 1=="hej"; | Compiler Error: 1:Bad argument 2 to `==.
I guess it's the same problem as above with 1==2.
/ Mirar
Previous text:
2003-02-12 12:52: Subject: Search bug ?
Am I missing something or is it a bug ? :
search(({ 1, 2, 3 }), 5);
Compiler Error: 1:Bad argument 2 to search.
[...]
search(({ 1, 2, 3 }), 1);
(1) Result: 0
search(({ 1, 2, 3 }), -8);
(2) Result: -1
Yes, it's a bug, you ought to have received a compilation error here too.
The problem is that typeof(-8) evaluates to int and not int(-8..-8) in an un-optimized context:
search(({ 1, 2, 3 }), -8);
(1) Result: -1
typeof(-8);
(2) Result: int
array(int(0..3)) a; search(a, -8);
Compiler Error: 1:Bad argument 2 to search. [...]
Search returns an error when I search for something which is greater than the greater element of the array. It does this with either Pike 7.2 or 7.4.
search() does not return an error. The type system inferes that you are writing code that is not meaningful, and thus causes a compilation error.
/ Henrik Grubbström (Lysator)