Hi Rob,
Thanks to your observations, I noticed that some equality checks in BaseX have been buggy since a fairly long time (since BaseX 10.x). This resulted in local:f1#2 and local:f2#2 being treated as identical function items, although the parameter types were different. Some future optimizations may have led to a situation where parts of your code were evaluated in a wrong way.
More specifically, if/switch branches that are not evaluated at runtime should cause no compile-time errors. Specifically, even if BaseX evaluates a switch case at compile time with the given variable values, an error should not caught immediately, but only if this branch is really evaluated later on. For example, the following code…
switch(<a/>)
case 'x' return 1 div 0
default return 'ok'
…is rewritten to the following expression (as can be seen in the info view of the GUI)…
if((<a/> = "x")) {
} else {
"ok"
}
In your code, I guess that the error was directly raised. But that’s wild guessing and would need further research. All I can say is that buggyDemo.xq can be evaluated with the current snapshot [1].
Hope this helps,
Christian