{"action":"created","issue":{"url":"https://api.github.com/repos/BaseXdb/basex/issues/1140","labels_url":"https://api.github.com/repos/BaseXdb/basex/issues/1140/labels{/name}","comments_url":"https://api.github.com/repos/BaseXdb/basex/issues/1140/comments","events_url":"https://api.github.com/repos/BaseXdb/basex/issues/1140/events","html_url":"https://github.com/BaseXdb/basex/issues/1140","id":75649204,"number":1140,"title":"Wrong Xquery behaviour","user":{"login":"VincentBiragnet","id":1266347,"avatar_url":"https://avatars.githubusercontent.com/u/1266347?v=3","gravatar_id":"","url":"https://api.github.com/users/VincentBiragnet","html_url":"https://github.com/VincentBiragnet","followers_url":"https://api.github.com/users/VincentBiragnet/followers","following_url":"https://api.github.com/users/VincentBiragnet/following{/other_user}","gists_url":"https://api.github.com/users/VincentBiragnet/gists{/gist_id}","starred_url":"https://api.github.com/users/VincentBiragnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VincentBiragnet/subscriptions","organizations_url":"https://api.github.com/users/VincentBiragnet/orgs","repos_url":"https://api.github.com/users/VincentBiragnet/repos","events_url":"https://api.github.com/users/VincentBiragnet/events{/privacy}","received_events_url":"https://api.github.com/users/VincentBiragnet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-12T15:54:51Z","updated_at":"2015-05-12T17:06:31Z","closed_at":null,"body":"The query below does not output expected result:\r\n\r\n```\r\ndeclare namespace local = \"local\"; \r\n\r\ndeclare function local:test($nodes as node()*){\r\n  let $numbers := (2,3)\r\n  return for $n at $k in $numbers\r\n         return $nodes/*[$numbers[$k]]          \r\n};\r\n\r\nlocal:test((<c><c0/><c1/></c>, <d><d0/><d1/><d2/></d>))\r\n```\r\n\r\nBut it works with tiny modifications: \r\n\r\n* without function call\r\n\r\n```\r\nlet $nodes := (<c><c0/><c1/></c>, <d><d0/><d1/><d2/></d>),\r\n    $numbers := (2,3)\r\nreturn for $n at $k in $numbers\r\n       return $nodes/*[$numbers[$k]]\r\n```\r\n\r\n* when using `position()`:\r\n\r\n```\r\ndeclare namespace local = \"local\"; \r\n\r\ndeclare function local:test($nodes as node()*){\r\n  let $numbers := (2,3)\r\n  return for $n at $k in $numbers\r\n         return $nodes/*[position() = $numbers[$k]]          \r\n};\r\n\r\nlocal:test((<c><c0/><c1/></c>, <d><d0/><d1/><d2/></d>))\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/BaseXdb/basex/issues/comments/101351583","html_url":"https://github.com/BaseXdb/basex/issues/1140#issuecomment-101351583","issue_url":"https://api.github.com/repos/BaseXdb/basex/issues/1140","id":101351583,"user":{"login":"ChristianGruen","id":196589,"avatar_url":"https://avatars.githubusercontent.com/u/196589?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianGruen","html_url":"https://github.com/ChristianGruen","followers_url":"https://api.github.com/users/ChristianGruen/followers","following_url":"https://api.github.com/users/ChristianGruen/following{/other_user}","gists_url":"https://api.github.com/users/ChristianGruen/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianGruen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianGruen/subscriptions","organizations_url":"https://api.github.com/users/ChristianGruen/orgs","repos_url":"https://api.github.com/users/ChristianGruen/repos","events_url":"https://api.github.com/users/ChristianGruen/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianGruen/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T17:06:31Z","updated_at":"2015-05-12T17:06:31Z","body":"Confirmed… Slightly smaller example:\r\n\r\n```xquery\r\ndeclare function local:test() {\r\n  for $n in (1, 1)\r\n  return <_><correct/><wrong/></_>/*[$n[1]]\r\n};\r\nlocal:test()\r\n```"}}