Opened 10 years ago

Closed 10 years ago

#2815 closed defect (fixed)

Reduction fails using polymorphic types

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: high Milestone: Bootstrapping
Component: MetaModelica Version: trunk
Keywords: Cc:

Description

This seems like something that should work:

function test
protected
  list<list<Integer>> ll := {{1}, {2}};
  list<Integer> l := listAppend(e for e in ll);
end test;

Currently it gives an error though:

Reductions require the types of the reduction expression and first argument
to be compatible, but got: list<#Integer> and list<polymorphic<A>>.

Change History (3)

comment:1 by Martin Sjölund, 10 years ago

Currently, only reductions with signature A,A->A are supported. I think I would like A,B->B to also be handled. But listAppend should be possible to make work. It does require using the polymorphic type matching though.

comment:2 by Martin Sjölund, 10 years ago

I have this working the way it should, but error handling is now horrible (I will try to fix it before a commit).
I used the following script for testing:

setCommandLineOptions("+g=MetaModelica");loadString("function test
  input list<list<Integer>> ll := {{1}, {2}};
  output Integer i := intAdd(e for e in {1,2});
  output list<Integer> l1 := listAppend(e for e in ll);
  output list<Integer> l2 := listAppend(e for e in {});
  output list<Integer> l3 := cons(e for e in {});
  output list<Integer> l4 := cons(e for e in ll);
end test;");getErrorString();
setCommandLineOptions("+d=evalfunc,nogen");
test();getErrorString();
setCommandLineOptions("+d=noevalfunc,gen");
test();getErrorString();

comment:3 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r22288, including folding A,B->B.

Note: See TracTickets for help on using tickets.