rql #92854 Variable sharing betwee OR branches is ambiguous [open]

We have a Workflowable entity X. We want it to be mutable while in state "setup", but not in state "ready". The point is some relation rel, mandatory on X, has an update permissions of U has_update_permission S. Thus the entity X needs also be mutable while not yet initialized, i. e. when not having any in_state relation.

The following update permission does not work : it gives update permission to the entity even when in state "ready"

'X owned_by U, '
'( (X in_state ST, ST name "setup") '
'  OR NOT EXISTS (X in_state ST) )'

But the following does work (note the ST2 variable instead of ST in the second clause of the OR):

'X owned_by U, '
'( (X in_state ST, ST name "setup") '
'  OR NOT EXISTS (X in_state ST2) )'

This is surprising and needs to be fixed - should it be considered a bug - and/or documented - should the simplicity of this behavior be considered as a feature.

priorityminor
typebug
done in<not specified>
load0.300
load left0.300
closed by<not specified>