Hi Dmitri,
Nope, this is not a bug.
The trick here is that there is a context change when you do a filtration: inside the square brackets (or, more precisely, inside the "where" function which is aliased by square brackets in 0.2.x) the $ variable changes its meaning: it means the current element of a collection, not the initial input.
So, if you want to achieve such a filtering behaviour, you need to save the value of uid at some other variable which would not be overwritten when the context changes. In 0.2.x you may use "as" function for this.
The expression should look like this:
$.as($.uid=>uid).user_data[$.tenant_id=int($uid)]
"As" function accepts a tuple, in which is first element is an expression to be evaluated on a passed data ($.uid in this case) and the second element is a string. The result of the evaluation will be saved in the context in a new variable having the name equal to the second element of the tuple. So, in all subsequent functions of the chain this value will be accessible by the appropriate variable name ($uid in this case - notice that there is no dot after the $)
Also, notice the usage of int() function - it is needed indeed, as the initial $.uid is string and tenant_id in each item is an integer. Another option would be to cast the value to int when saving in context instead of when doing comparison, like this:
$.as(int($.uid)=>uid).user_data[$.tenant_id=$uid]
This statement has a slightly better performance on large collections, as the string-to-integer casting happens only once (when the variable is created), while the previous one does it for every element in the collection.