Hi Rob,

this change was caused by a recent reorganization of how BaseX manages user-defined functions. As part of that work, `fn:function-lookup` became stricter and only found functions that are statically visible at the call site of `fn:function-lookup`.

The XQuery 4.0 spec guarantees access to statically visible functions, but it leaves the behavior for other functions implementation-defined. In earlier BaseX versions, functions imported anywhere in the query could also be found by `fn:function-lookup`, and your example relied on that behavior.

We have now restored that behavior in the latest snapshot as a fix for #2641, which was opened from your original report. For some implementation details, see #2644.

Private functions remain excluded unless they are looked up from a place where they are statically visible; this is required by the spec, and BaseX continues to enforce it.

Best regards
Gunther

#2641: https://github.com/BaseXdb/basex/issues/2641
#2644: https://github.com/BaseXdb/basex/pull/2644

Gesendet: Montag, 20. April 2026 um 12:07
Von: "Christian Grün via BaseX-Talk" <basex-talk@mailman.uni-konstanz.de>
An: "basex-talk@mailman.uni-konstanz.de" <basex-talk@mailman.uni-konstanz.de>, "Rob Stapper" <r.stapper@lijbrandt.nl>
Betreff: [basex-talk] Re: changed "function-look"-behavior in BaseX version 12.3
Hi Rob,

Thanks, you are right: The function should still be found, even if it is located in another module. We’ll track this down soon [1].

Best,
Christian

[1] https://github.com/BaseXdb/basex/issues/2641
________________________________________

Von: Rob Stapper via BaseX-Talk <basex-talk@mailman.uni-konstanz.de>
Gesendet: Freitag, 17. April 2026 11:24
An: basex-talk@mailman.uni-konstanz.de
Betreff: [basex-talk] changed "function-look"-behavior in BaseX version 12.3

Hi,

Version 12.3 now requiers the module where the function is fetched from, to be imported in the same module as where the "function-lookup"-function is called from. Before this wasn't the case, the module only needed to be imported in the module where the qName for the function is created. So I could have a module for generic function retrieval. Those days seem to be over.

Is this behaviour to stay or can it be reversed.

(app.xqm)
import module namespace c = "_function-lookup-test.c" ;
import module namespace m = "_function-lookup-test.m" ;
c:method( xs:QName( "m:test")
, 0
)()

(m.xqm)
module namespace m = "_function-lookup-test.m" ;
declare %public function m:test( ) { "test"} ;

(c.xqm)
module namespace c = "_function-lookup-test.c" ;
(: Basex 12.3 requiers the lookup-module to be imported in the module that executes the 'function-lookup'-function
in previous versions this was not necessary, the-lookup-module only needed to be imported in the calling module, here: "m.xqm"
import module namespace m = "_function-lookup-test.m" ; (: not working anymore since 123 when not active :)
:)
declare %public function c:method
( $qName as xs:QName
, $arity as xs:integer
) as function(*)?
{ function-lookup( $qName
, $arity
)
otherwise message( "WARNING!: Method not found: " || xs:string( $qName) || "#" || $arity
)
} ;

Best.

Rob Stapper