Opened 10 years ago

Closed 10 years ago

#2925 closed defect (fixed)

Functions use default value instead of actual value

Reported by: perost 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 Changed 10 years ago by sjoelund.se

  • Component changed from Bootstrapping to Frontend
  • Milestone Bootstrapping deleted
  • Owner changed from sjoelund.se to somebody
  • Summary changed from List comprehensions use default value instead of actual value to Functions 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 Changed 10 years ago by perost

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r23407.

Note: See TracTickets for help on using tickets.