Question: Object does not have a moduleIterator error

This is another one of those problems that shows up only when I put all my modules in a lib and run the program, and unable to make a MWE in the worksheet.

Here is description of the problem. There is a module which is an object, which has no method. Just variables. 

export SUM_type:=module()
   option object;
   export starting_index::integer;
   export body;
   export power_on_x;
   export actual_sum;   
end module;

some where inside the program, a list is created of such objects. This problem only shows up when there is ONE object in the list. Where there is 2 or more objects in the list, no problem. The problem shows up here

for tmp in op(THE_SUMS) do    #BUG IN MAPLE  
        new_ode := new_ode + tmp:-actual_sum;

The above code is from inside a proc in a module. The variable THE_SUMS is the list and tmp is just a local variable.

In the debugger, once I step in the loop, it generates an exception

The strange thing, this only happens when there is ONE object in the list and not more. Here are screen shot from the debugger window

To avoid this, I changed the loop to the following, and not it works with one or more entries in the list

   for N from 1 to nops(THE_SUMS) do
       tmp := THE_SUMS[N];
       new_ode := new_ode + tmp:-actual_sum;

And this work. I spend a lot of time trying to make a MWE, but it works ok in worksheet. It looks like a scoping issue. I do not use ModuleIterator, and do not need it. When I added one to the object above just to see what happens, I saw the ModuleItrator being called. I have no idea why Maple wants to call it when there is one object in the list.

Here is one attempt on a MWE. but this gives no error. 

   option object;
   export starting_index::integer;
end module;
for item in L do  #OK here since in global name space?

I am just repoting this in case someone have seen it before. I have a workaround it as I showed, which is to avoid using `for temp in list` when the list has objects in it.

Maple 2021.1 on windows 10

Please Wait...