Opened 12 years ago

Closed 12 years ago

#2262 closed defect (fixed)

empty vector as first argument to change

Reported by: Lennart Ochel Owned by: Lennart Ochel
Priority: blocker Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Cc: Martin Sjölund

Description

model test
  Boolean b[0];
  anyChange ac(vec = b);
  Integer d(start = 0, fixed = true);
equation
  when ac.anychange then
      d = pre(d) + 1;
  end when;
end test;

block anyChange "does any entry of a boolean vector change its value?"
  input Boolean vec[:];
  output Boolean anychange;
algorithm
  anychange:=false;
  for i in 1:size(vec, 1) loop
    anychange:=anychange or change(vec[i]);
  end for;
end anyChange;

Error Message:

"[<interactive>:8:7-8:45:writable] Error: First argument to change in component ac must be a variable.
Error: Error occurred while flattening model test
"

Change History (6)

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

Owner: changed from somebody to Martin Sjölund
Status: newaccepted

comment:2 by Lennart Ochel, 12 years ago

This can be used as test case:

model Test
  Boolean b[0];
  Boolean anychange;

algorithm
  anychange := false;
  for i in (1:size(b, 1)) loop
    anychange := anychange or change(b[i]);
  end for;
end Test;

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

It is a problem with trying to determine if it is discrete or not by looking at the elaborated expression and lookupVar. Which will fail to detect variables that become discrete due to when-sections. It should probably be possible to relax these checks and instead do them in the backend...

comment:4 by Martin Sjölund, 12 years ago

Fixed in r16481. Add the testcase (to both ModelicaCompliance and trunk/testsuite I guess) and close the ticket :)

Last edited 12 years ago by Martin Sjölund (previous) (diff)

comment:5 by Martin Sjölund, 12 years ago

Owner: changed from Martin Sjölund to Lennart Ochel
Status: acceptedassigned

comment:6 by Lennart Ochel, 12 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.