Is this a bug in the PL/SQL Compiler?

В нашем репозитории SVN-кода я наткнулся на спецификацию пакета, которая - после удаление нескольких строк - сводится к

create or replace package tq84 as
    return varchar2(10);
end tq84;
/

Мне кажется, что такая спецификация не имеет большого смысла и поэтому should not compile at all. But maybe, I don't see the obvious, so: is this really a bug?

For completness' sake:

me @ xxx.yyy.zz > select * from v$version;
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production

Edit: it has been suggested that in specification as given above return is not the keyword but a (package-)variable. This seems not to be the case however, since the following compiles equally fine:

create or replace package tq84 as

    return varchar2(10);
    return number;
    return date;

end tq84;
/

and clearly, the compiler should tell me that I declare the same variable multiple times.

EDIT 2: JOTN is right, of course, and return IS a variable, and furthermore, the compiler doesn't tell upfront, if a variable with the same name is declared twice or more, instead, it's the runtime environment, that does.

So, with that in mind, it's possible to compile something like

create or replace package return as
  subtype return is varchar2(10);
end return;
/

create or replace package tq84 as

    constant constant 

    return . return := 'return';

    function function 

    return   return . return;

end tq84;
/

which looks strange, at least at first sight.

So then, I guess, it's not a compiler bug because return is allowed as a variable name, but then, it's disputable if the compiler should at least give a warning if a variable with the same name is declared multiple times.

14
задан René Nyffenegger 22 December 2010 в 15:35
поделиться