On 10 Jul 2013, at 10:07, Damian Steer <[email protected]> wrote: > > On 9 Jul 2013, at 21:01, Joshua TAYLOR <[email protected]> wrote: > >> prefix : <http://example.org/> >> >> select ?element ?index ?element2 ?index2 where { >> ?element :atIndex ?index . >> OPTIONAL { >> FILTER( ?index - 1 = ?index2 ) >> ?element2 :atIndex ?index2 . >> } >> } >> order by ?index >> >> >> produces results that actually show that ?index2 is constrained, and >> are almost the same the as the first query (except that the case where >> ?index2 is -1 doesn't occur): > > Ok, _now_ I'm scratching my head.
Just to expand on why I'm scratching my head. It really, really looks like ?index is bound to 0 in the optional block. I expected it to act like FILTER( ?unbound - 1 = ?index2 ) (always false), but that's not the case since you'd never find a solution where ?element2 and ?index2 are bound. Then I wondered whether the filter was being moved to the outer block, but that's rather different again -- you're filtering a cross product essentially, and won't get 'ragged' results (ones where some variables are unbound). I'm voting 'bug'. Damian
