SPARQL subqueries are evaluated from the innermost to the outermost. A values block in an outer query isn't available to the inner queries. As an example:
select ?x ?y ?z {
values ?x { "x" }
{ select (?x as ?y) ("z" as ?z) {} }
}
-----------------
| x | y | z |
=================
| "x" | | "z" |
-----------------
If the value of ?x had been available in the inner query, then ?y would have the value "x", but it doesn't.
On the other hand, bindings from a values block in a subquery can be passed outward, if they are selected. For instance, in this query, the subquery binds ?x and ?y, but only projects ?x:
select ?x ?y {
{
select ?x {
values ?x { "x" }
values ?y { "y" }
}
}
}
-----------
| x | y |
===========
| "x" | |
-----------
The official answer is in the spec, but not in the part about values. It's in 18.2.1 Variable Scope. It's not the easiest table to follow, but the thing to note is rules like:
Group { P1 P2 … } : v is in-scope if it is in-scope in one or more of P1, P2, …
which means that the set of in-scope variables for a pattern { ... }
is defined as the union of the in-scope variables of the things that appear within in. Variables get "passed" outward to the their enclosing forms, not the other way around.
There's one exception to that, I think, which is a values block that's outside the outermost query, which, I think, is pretty much the same as a values block inside the outermost query:
select ?x ?y ?yy {
{ select (?y as ?yy) {} }
}
values (?x ?y) { (1 2) }
--------------
| x | y | yy |
==============
| 1 | 2 | |
--------------