Incorrectly parsing a sequence path having group element and followed by Value constant

Description

Sparql parser produces wrong query tree when parsing proprty path composed of group element and sequence when it is followed by value constant.

This query:
ASK {?relation (<w-mrimaryArticle>)/<w-m:belongsToJournal> <w-m:Journal>}

end up with such query model:
Slice ( limit=1 )
Join
StatementPattern
Var (name=relation)
Var (name=-const-1, value=w-mrimaryArticle, anonymous)
Var (name=-const-2, value=w-m:Journal, anonymous)
StatementPattern
Var (name=relation-nested-0, anonymous)
Var (name=-const-4, value=w-m:belongsToJournal, anonymous)
Var (name=-const-5, value=w-m:Journal, anonymous)

look at the object component of the first StatementPattern - it should be the same as the subject element of the second statement pattern but instead, it refers to the Value constant of the object component of the second pattern

when the query is changed so to use variable instead of the constat, e.g. like that:

ASK {?relation (<w-mrimaryArticle>)/<w-m:belongsToJournal> ?journal}

the generated query model is correct:

Slice ( limit=1 )
Join
StatementPattern
Var (name=relation)
Var (name=-const-1, value=w-mrimaryArticle, anonymous)
Var (name=relation-nested-0, anonymous)
StatementPattern
Var (name=relation-nested-0, anonymous)
Var (name=-const-2, value=w-m:belongsToJournal, anonymous)
Var (name=journal)

it is present at least from 2.6.10 onwards - didn't check further back

Environment

None

Status

Assignee

Jeen Broekstra

Reporter

Damyan Ognyanov

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure