Gesendet: Mittwoch, 3. Juni 2026 um 13:43
Von: "Andreas Hengsbach | nexoma via BaseX-Talk" <basex-talk@mailman.uni-konstanz.de>
An: "BaseX Mailinglist" <basex-talk@mailman.uni-konstanz.de>
Betreff: [basex-talk] NPE in FuncRef.has(): missing null guard causes crash when imported function is used in .[] step's and-predicate (since 12.2)
Hi everyone,
I found a bug and used AI to narrow it down to the smallest possible reproducer.
I hope this helps.
### schnipp
(: Reproducer for BaseX bug: NPE in Single.has() via Step.get()
Affected versions: 12.2, 12.3, 12.4
Not affected: 12.0, 12.1
Required conditions (all three necessary):
1. .[] step — Path.get() converts Filter(ContextValue, preds) to Step.get(SELF, preds)
2. compound `and` predicate — creates an Arr containing the FuncRef
3. imported module function as an operand — unresolved at parse time -> FuncRef(expr=null)
FuncRef extends Single but has no has() override -> Single.has() NPEs on null expr
Fix: add has() override to FuncRef inner class in StaticFuncs.java (analogous to accept()):
@Override
public boolean has(final Flag... flags) {
return expr != null && expr.has(flags);
}
:)
import module namespace functx = "http://www.functx.com";
<a/>/.[true() and functx:all-whitespace('')]
### schnapp
Best regards,
Andreas