weirdness w/ternary operator (a?b:c)
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=2677
Reported by Martin Stjernholm mast@roxen.com
From: "Robert J. Budzynski" <Robert.Budzynski@fuw.edu.pl>
Subject: weirdness w/ternary operator (a?b:c)
To: pike@roxen.com
Date: Sun Jan 13 02:12:14 2002 +0100
Pike v7.2 release 234 running Hilfe v2.0 (Incremental Pike Frontend)
> mixed foo(mixed x){return x?(write("FOO\n"),"FOO"):werror("BAR\n");}
> foo(1);
FOO
Result: 1
> foo(0);
BAR
Result: 0
> mixed fooo(mixed x){return
x?(write("FOO\n"),"FOO"):(werror("BAR\n"),"BAR");}
> fooo(0);
BAR
Result: "BAR"
> fooo(1);
FOO
Result: "FOO"
Note that while fooo() works correctly, the return value of foo(1) is bogus. Pike is getting confused when the third arg of the ternary operator (the `c' in a?b:c) is a call to a function of return type void.