felipebz / zpa

Parser and static code analysis tool for PL/SQL and Oracle SQL.
https://zpa.felipebz.com
GNU Lesser General Public License v3.0
211 stars 77 forks source link

Collections seen as METHOD_CALL #132

Closed jorge-agra closed 4 years ago

jorge-agra commented 4 years ago

Hi, first of all, thanks for the great work.

I've encountered an issue with collections references that show up as function calls. Please check the code below.

Best regards.

create or replace procedure prc1(x number) as TYPE xpto_tbl IS TABLE OF varchar2(100) INDEX BY pls_integer; col1 xpto_tbl := xpto_tbl(); begin col1(1) := 'A'; -- col1(1) shows as a METHOD_CALL AstNode end; /

felipebz commented 4 years ago

Hi @jorge-agra.

Unfortunately, I don't think if it's possible to fix this in the parser. Some situations like yours are "simple", we know that PL/SQL doesn't allow <method call> := <value>. But let's say we're parsing this code:

dbms_output.put_line(col1(1));

What is "col1": a function call or a collection access? I'm afraid that identifying and creating different nodes for procedures/functions and collection accesses would require a big change in the parser.

Is this causing any problem for you? Maybe I could suggest or implement a way to guess if a METHOD_CALL is a collection access...

jorge-agra commented 4 years ago

Hi Felipe, thanks for answering, I was already guessing it would not be a simple thing...

No problem that cannot be solved. Right now, we are using the symbol table to double check. Is a bit more complex but works. Best regards.