Hi list,
Am I missing something or is it a bug ? :
search(({ 1, 2, 3 }), 5);
Compiler Error: 1:Bad argument 2 to search. Compiler Error: 1:Expected: function(string, string | int, void | int : int) | function(array((0=mixed)), 0, void | int : int) | function(mapping((1=mixed):(2=mixed)), 2, void | 1 : 1) | !(function(!array, mixed, void | int : mixed) | function(!mapping, mixed, void | int : mixed)) & function(mapping | array, mixed, void | int : zero) Compiler Error: 1:Got : function(array(int(1..3)), int(5..5) : void | mixed)
search(({ 1, 2, 3 }), 1);
(1) Result: 0
search(({ 1, 2, 3 }), -8);
(2) Result: -1
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.
Thank you for your answers.
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)
Previous text:
2003-02-12 12:14: Subject: Search bug ?
Hi list,
Am I missing something or is it a bug ? :
search(({ 1, 2, 3 }), 5);
Compiler Error: 1:Bad argument 2 to search. Compiler Error: 1:Expected: function(string, string | int, void | int : int) | function(array((0=mixed)), 0, void | int : int) | function(mapping((1=mixed):(2=mixed)), 2, void | 1 : 1) | !(function(!array, mixed, void | int : mixed) | function(!mapping, mixed, void | int : mixed)) & function(mapping | array, mixed, void | int : zero) Compiler Error: 1:Got : function(array(int(1..3)), int(5..5) : void | mixed)
search(({ 1, 2, 3 }), 1);
(1) Result: 0
search(({ 1, 2, 3 }), -8);
(2) Result: -1
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.
Thank you for your answers.
-- David Gourdelier
/ Brevbäraren
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)
It might be when using macros, which probably goes for the other examples as well.
/ Martin Nilsson (Åskblod)
Previous text:
2003-02-12 13:28: Subject: Search bug ?
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
pike-devel@lists.lysator.liu.se