Using 5.1.1 and knowing that "a Return Value restriction is a parenthesized expression composed from literals, any valid Java primitive or object, previously bound variables, function calls, and operators" I wrote

  OperatorOrder( $code: code, $id1: elId1, $id2: elId2 )
  CommandCode( code == $code, operands != ( $id1!=null ? ($id2!=null ? 2 : 1) : 0 ) )

and got the erroneous error message:
   Rule Compilation error : [Rule name='operator command: invalid number of elements']
       appl/domain/element/Rule_operator_command__invalid_number_of_elements_0.java (9:714) : $id2 cannot be resolved

Variations in the return value restriction show that it is the nesting of -?-:- which causes the bug; a similar (but not equivalent) expression

   operands != ( ($id1!=null ? 1:0) + ($id2!=null ? 1:0) )

is accepted.
-W