#55 JLS 15.22.2 Boolean Logical Operators

open
nobody
Parsing (77)
2
2002-04-02
2002-04-02
No

JLS 15.22 talks about operators &, | and ^ in a
boolean context. This is not implemented in BeanShell:

bsh % false | false;
// Error: Internal Error: unimplemented binary operator
bsh.InterpreterError: unimplemented binary operator
at bsh.Primitive.booleanBinaryOperation
(Primitive.java:245)
at bsh.Primitive.binaryOperationImpl
(Primitive.java:208)
at bsh.Primitive.binaryOperation
(Primitive.java:191)
at bsh.BSHBinaryExpression.eval
(BSHBinaryExpression.java:131)
at bsh.Interpreter.run(Interpreter.java:420)
at bsh.Interpreter.main(Interpreter.java:370)

Following is an example of use of the boolean |
operator:

bsh % boolean test(a, b) { print("test " + a); return
b; }
bsh % test(1, true) || test(2, true);
test 1
bsh % test(1, true) | test(2, true);
test 1
test 2

The last will not work correctly, due to the error
above.

This is a low-priority bug, reported mainly to
document Java compability.

Discussion

    • priority: 5 --> 2