Opened 10 years ago

Closed 10 years ago

#2925 closed defect (fixed)

Functions use default value instead of actual value

Reported by: Per Östlund Owned by: somebody
Priority: high Milestone:
Component: Frontend Version: trunk
Keywords: Cc:

Description

The following model returns {1} instead of the expected {2}:

function test
  output list<Integer> lst := {1};
algorithm 
  lst := {2};
  lst := list(e for e in lst);
end test;

It seems like list comprehensions somehow use the default value of the list instead of the actual value.

Change History (2)

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

Component: BootstrappingFrontend
Milestone: Bootstrapping
Owner: changed from Martin Sjölund to somebody
Summary: List comprehensions use default value instead of actual valueFunctions use default value instead of actual value

This is true also for Modelica functions:

function test2
 output Integer lst[:] := {1};
algorithm
 lst := {2};
 lst := array(e+3 for e in lst);
end test2;

model M
  Real arr[:] = test2();
end M;

Gives:

function test2
  output Integer[1] lst = {1};
algorithm
  lst := {2};
  lst := {4};
end test2;

comment:2 by Per Östlund, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r23407.

Note: See TracTickets for help on using tickets.