#250 Spurious "duplicate function" error in XQuery

v8.1
closed
Michael Kay
5
2014-04-02
2004-09-29
Michael Kay
No

The XQuery parser may report that duplicate function
declarations exist when they do not.

The error is new in 8.1 and results from an incorrect
calculation of a key that combines the function name
and arity.

The calculation is written as

Long keyObj = new Long(((long)arity)<<32 + (long)fp);

which should be

Long keyObj = new Long((((long)arity)<<32) + (long)fp);

because + has higher precedence than <<.

The incorrect calculation appears in five places in
module XQueryFunctionLibrary.java: on lines 74, 105,
155, 197, and 264.

(Also, line 154 should be

int fp = getNamePool().allocate("", uri, local) &

0xfffff;

to mask off any differences in the prefix used for the
function name)

Source code fixed.

Discussion