declarative4all icon indicating copy to clipboard operation
declarative4all copied to clipboard

Having another FLWOR expression inside 'if' fails

Open hfmanson opened this issue 3 years ago • 2 comments

For example running this query inside runany.htm:

let $x := 4
return
  if ($x eq 4) then
    let $y := 5
    return $y
  else
    7

returns

18:37:54 - fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPST0003'),'Cannot read properties of undefined (reading 'length')')

hfmanson avatar Oct 05 '21 16:10 hfmanson

There are issues in the current parser resulting with this kind of error message.

As a workaround, adding extra parentheses around an embedded FLWOR expression, or an embedded if statement, should help enough the parser and allow evaluation.

A new version of parser is to be committed soon.

AlainCouthures avatar Oct 08 '21 12:10 AlainCouthures

Indeed

let $x := 4
return
  if ($x eq 4) then
  (
    let $y := 5
    return $y
  )
  else
    7

returns

15:10:37 - xs:integer('5')

hfmanson avatar Oct 08 '21 13:10 hfmanson