Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5445 closed defect (fixed)

[NF] Synchronous operators are not allowed in if condition

Reported by: anonymous Owned by: perost
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 Changed 5 years ago by perost

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

Fixed in b726183e.

comment:2 follow-up: Changed 5 years ago by anonymous

Still not work in b7a2c6913

comment:3 in reply to: ↑ 2 Changed 5 years ago by perost

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 Changed 5 years ago by gossen

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.