AlainCouthures / declarative4all

XQuery and XForms implementations written in Javascript
Other
28 stars 7 forks source link

Having another FLWOR expression inside 'if' fails #4

Open hfmanson opened 2 years ago

hfmanson commented 2 years ago

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')')
AlainCouthures commented 2 years ago

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.

hfmanson commented 2 years ago

Indeed

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

returns

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