Hi, BaseX team.

I'm reporting an exception I saw in BaseX 12.4 in a function call where the fn:replace function refers to $1 in the third argument without having any parenthesized expressions in the second argument. The function call has a mistake, but I'm assuming BaseX should respond differently.

replace('full stop.','\.','\\$1')

Could not execute XQUERY replace('full stop.','\.','\\$1'):
Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 12.4
Java: Eclipse Adoptium, 17.0.17
OS: Windows 11, amd64
Stack Trace:
java.lang.IndexOutOfBoundsException: No group 1
at java.base/java.util.regex.Matcher.start(Matcher.java:482)
at java.base/java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1090)
at java.base/java.util.regex.Matcher.appendReplacement(Matcher.java:997)
at java.base/java.util.regex.Matcher.replaceAll(Matcher.java:1181)
at org.basex.query.func.fn.FnReplace.item(FnReplace.java:103)
at org.basex.query.func.fn.FnReplace.item(FnReplace.java:22)
at org.basex.query.expr.ParseExpr.value(ParseExpr.java:71)
at org.basex.query.CompileContext.preEval(CompileContext.java:257)
at org.basex.query.func.StandardFunc.optimize(StandardFunc.java:79)
at org.basex.query.expr.Arr.compile(Arr.java:49)
at org.basex.query.func.StaticFuncs$FuncRef.compile(StaticFuncs.java:358)
at org.basex.query.scope.MainModule.compile(MainModule.java:38)
at org.basex.query.QueryCompiler.compile(QueryCompiler.java:41)
at org.basex.query.QueryContext.compile(QueryContext.java:369)
at org.basex.query.QueryContext.lambda$compile$2(QueryContext.java:312)
at org.basex.query.QueryContext.run(QueryContext.java:792)
at org.basex.query.QueryContext.compile(QueryContext.java:298)
at org.basex.query.QueryProcessor.compile(QueryProcessor.java:78)
at org.basex.core.cmd.AQuery.init(AQuery.java:203)
at org.basex.core.cmd.AQuery.updating(AQuery.java:150)
at org.basex.gui.GUI.execute(GUI.java:421)
at org.basex.gui.GUI.lambda$execute$5(GUI.java:375)
at java.base/java.lang.Thread.run(Thread.java:840)

Best regards,
Amanda