Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5445 closed defect (fixed)

[NF] Synchronous operators are not allowed in if condition

Reported by: anonymous Owned by: Per Östlund
Priority: high Milestone: Future
Component: New Instantiation Version:
Keywords: synchronous Cc:

Description

In the new instantiation, it isn't possible to use synchronous operators in if equation condition

model Example
  Real x = time;
  Real y;
  parameter Boolean cond = false;
  
equation
  when Clock() then
    if sample(cond) then
      y = sample(x);
    else
      y = 0;
    end if;
  end when;
  
end Example;

// ~/OpenModelica/OMCompiler/Compiler/NFFrontEnd/NFCeval.mo: 1657:9-1658:51]:
//   Internal error NFCeval.evalBuiltinCall: unimplemented case for sample

The same error happened with other synchronous operators, like hold.

Change History (4)

comment:1 by Per Östlund, 6 years ago

Resolution: fixed
Status: newclosed

Fixed in b726183e.

comment:2 by anonymous, 6 years ago

Still not work in b7a2c6913

in reply to:  2 comment:3 by Per Östlund, 6 years ago

Replying to anonymous:

Still not work in b7a2c6913

You probably have the -d=evaluateAllParameters flag turned on in that case, it can't quite handle cases such as this yet. OMEdit had that flag turned on by default for a brief period of time, but that was fixed last week.

comment:4 by Maksimov Doe, 6 years ago

You are right, with flag +d=-evaluateAllParameters instantiation correctly works for all operators, except backSample, shiftSample, noClock and hold.

model Example
  Real x;
  Real y;
  parameter Boolean cond = false;
  
equation
  when Clock() then
    x = time;
  end when;
  
  if hold(cond) then
    y = hold(x);
  else
    y = 0;
  end if;
  
end Example;
Note: See TracTickets for help on using tickets.