title: Passing an associative array to a function within an procedure throws PLS-00382 expression is of wrong type
body: <p>I have the following types:</p>
  
  <pre><code>CREATE OR REPLACE TYPE num_t AS OBJECT
  (
    c1 number,
    MAP MEMBER FUNCTION sort_key RETURN VARCHAR2
  )
  CREATE OR REPLACE TYPE BODY num_t AS
     MAP MEMBER FUNCTION sort_key RETURN VARCHAR2 IS
     BEGIN
        RETURN c1;
     END;
  END;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>CREATE OR REPLACE TYPE num_tab AS TABLE OF num_t
  </code></pre>
  
  <p>My package is defined as follows:</p>
  
  <pre><code>create or replace package test_package is
  
    type t_test is table of number index by binary_integer;
    test_empty_array t_test;
  
    procedure test_proc(cur_out out sys_refcursor);
  
    function test_fn(i_test in t_test) return num_tab;
  
  end test_package;
  
  create or replace package body test_package is
  
    procedure test_proc(cur_out out sys_refcursor) is
      i_test t_test := test_empty_array;
    begin
      open cur_out for
        select * from table(test_fn(i_test));
  
    end;
  
    function test_fn(i_test in t_test) return num_tab is
      v_results num_tab;
    begin
      for i in i_test.first .. i_test.last loop
        v_results.extend;
        v_results(i) := num_t(c1 =&gt; i_test(i));
      end loop;
  
      return v_results;
    end;
  
  end test_package;
  </code></pre>
  
  <p>When I try to compile this, I get the following errors:</p>
  
  <pre><code>Error: PLS-00382: expression is of wrong type
  Line: 7
  Text: select * from table(test_fn(i_test));
  
  Error: PLS-00306: wrong number or types of arguments in call to 'TEST_FN'
  Line: 7
  Text: select * from table(test_fn(i_test));
  
  Error: PL/SQL: ORA-00904: "TEST_PACKAGE"."TEST_FN": invalid identifier
  Line: 7
  Text: select * from table(test_fn(i_test));
  
  Error: PL/SQL: SQL Statement ignored
  Line: 7
  Text: select * from table(test_fn(i_test));
  </code></pre>
  
  <p>It looks like it should work to me.  Any ideas?</p>