Improve user experience by detecting the typo in query instead of discarding faulty part
let $fn := function ($a) { $a }
return $fn({
"k": 2
"seed": 1
})
Error [err: SENR0001 ] Serialization error; Functions are not serializable.
The query given above has a typo at line 3: the comma is missing after "k": 2. Because of this, the entire object constructor expression and the dynamic functional call are discarded. The query that actually runs looks like this:
let $fn := function ($a) { $a }
return $fn
Hence, it triggers the functions are not serializable error as expected.
I was wondering if we can improve the grammar somehow, so that, instead of running a faulty query and giving a misleading error message, we can give a meaningful error to the user.
Edit: If the original query looks like this (notice the parenthesis around the return expression)
let $fn := function ($a) { $a }
return ($fn({
"k": 2
"seed": 1
}))
The following error is given which points to the correct address of the problem:
Error [err: XPST0003]LINE:5:COLUMN:14:Parser failed. "seed"
@CanBerker do you still have the issue. I fixed it at least on the shell and checked as well with a query file. It required an explicit EOF in the grammar file.
Looks much better now, nicely done!

Feel free to close the issue