No error upon (almost) duplicate function declarations

Bug #862971 reported by Paul J. Lucas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Medium
Markos Zaharioudakis

Bug Description

If you declare two XQuery functions that have the same name and signature (arity) in the same file, but the first is declared "external" and the second one isn't, Zorba allows the second declaration. It should be reported as an error.

Changed in zorba:
importance: Undecided → Medium
description: updated
Changed in zorba:
assignee: nobody → Markos Zaharioudakis (markos-za)
Changed in zorba:
milestone: none → 2.5
Changed in zorba:
status: New → Incomplete
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

I cannot reproduce the problem. What I did was add thie follwoing function:

declare function ext:bar3($i as xs:integer)
{
   $i + 2
};

in ext_mod.xq file (in test/unit) and then run the external_function unit test. I did get the expected error of duplicate function declaration.

Can you provide a complete specific test that shows the bug?

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

// foo.xq

module namespace foo = "http://www.foo.com";

declare function foo:f( $i as xs:integer ) external;

declare function foo:f( $i as xs:integer ) {
  $i + 2
};

// test.xq

import module namespace foo = "http://www.foo.com" at "/tmp/foo.xq";

foo:f(1)

// result
</tmp/foo.xq>:3,9: Zorba error [zerr:ZXQP0008]: "{http://www.foo.com}f#1": function implementation not found; raised at /Users/pjl/src/flwor/zorba/repo/trunk/zorba/src/compiler/translator/translator.cpp:3328

If you reverse the order of the function declarations (put the external one last), the query runs to completion without error and produces the expected result of "3".

In either case, it should instead complain that the same function has been multiply defined.

Changed in zorba:
status: Incomplete → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.