How to find nodes with a scalar predicate having values found during traversal

If I place val() as first argument to eq() function it works great. Is there any reason it behaves this way? @MichelDiz