I notice Basex has a util:eval function similar to the eXist db one however it is not clear for the BaseX version what the inherited context, if any, is. The example on the eXist site:

let $a := "Hello"
return util:eval("$a")

Fails with an undefined variable $a with BaseX 7.0.1

/Andy