Unable to execute queries where :find contains both pull expression and variable used in pull expression

According to find-specs it is possible to specify variables along with pull but when I execute the next query:

[:find ?user (pull ?user [*])
       :in $
       :where
       [?user :User/name ?name]
       ]

The error is returned: Execution error (ArrayIndexOutOfBoundsException) at (REPL:1).

It looks like the issue is exactly in ?user which is used in pull expression too, if to replace ?user on ?name then all is ok

[:find ?name (pull ?user [*])
       :in $
       :where
       [?user :User/name ?name]
       ]

Is it expected behavior?

Yes, you cannot have have the same binding twice in the query find clause. See this example from a project I was working on:

(d/q '[:find (pull ?e [:db/id :instrument/price :instrument/redemption-conditions])
       :where
       [?e :instrument/status "Active"]] (d/db conn))
=>
[[{:db/id 17592186045418, :instrument/price 105.5, :instrument/redemption-conditions "Redeemable after five years"}]
 [{:db/id 17592186045419, :instrument/price 250.0, :instrument/redemption-conditions "None"}]
 [{:db/id 17592186045422, :instrument/price 101.0, :instrument/redemption-conditions "Redeemable after five years"}]
 [{:db/id 17592186045423, :instrument/price 750.0, :instrument/redemption-conditions "Profit"}]
 [{:db/id 17592186045424, :instrument/price 10.0, :instrument/redemption-conditions "Buy Now"}]]
(d/q '[:find ?e (pull ?e [:db/id :instrument/price :instrument/redemption-conditions])
       :where
       [?e :instrument/status "Active"]] (d/db conn))
Execution error (ArrayIndexOutOfBoundsException) at datomic.datalog/fn$project (datalog.clj:501).
Index 1 out of bounds for length 1
(d/q '[:find ?e ?e
       :where
       [?e :instrument/status "Active"]] (d/db conn))
Execution error (ArrayIndexOutOfBoundsException) at datomic.datalog/fn$project (datalog.clj:501).
Index 1 out of bounds for length 1
1 Like