Opened 13 years ago

Last modified 13 years ago

#1637 closed defect (fixed)

Type-checking of if-expression modifiers is incorrect

Reported by: Per Östlund Owned by: Per Östlund
Priority: high Milestone:
Component: Version:
Keywords: Cc: Per Östlund, Per Östlund

Description

This model:

model M
  parameter Integer n = 2;
  Real r[n] = if n == 1 then {1} else {2, 3};
end M;

causes a type mismatch error because the elaboration of the if-expression returns only the type of the first branch. This is used in Modelica.Fluid.Pipes.DynamicPipe in the modification of the PartialTwoPortFlow extends clause.

Change History (3)

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

Static.makeIfexp - comment out the Types.semiEquivTypes case and almost all models start working. The remaining Media ones seem to have lingering redeclare issues...

comment:2 by Adrian Pop, 13 years ago

If I comment out this case:

    /*
    case (cache,env,e1,DAE.PROP(type_ = (DAE.T_BOOL(varLstBool = _),_),constFlag = c1),e2,DAE.PROP(type_ = t2,constFlag = c2),e3,DAE.PROP(type_ = t3,constFlag = c3),impl,st,_, _)
      equation
        true = Types.semiEquivTypes(t2, t3);
        c = constIfexp(e1, c1, c2, c3);
        (cache,exp) = cevalIfexpIfConstant(cache,env, e1, e2, e3, c1, impl, st, inInfo);
      then
        (cache,exp,DAE.PROP(t2,c));
    */

in Static.makeIfexp, all tests go:

adrpo@ida-liu050 ~/dev/OpenModelica/testsuite
$ cat testsuite-trace.txt | grep ====
==== Log /tmp/omc-rtest-adrpo/bootstrapping/log-SimCodeTest.mos
==== Log /tmp/omc-rtest-adrpo/meta/log-PartialFn13.mos
==== Log /tmp/omc-rtest-adrpo/mofiles/log-Discrete2.mo
==== Log /tmp/omc-rtest-adrpo/mofiles/log-SimpleTypeExtend.mo
==== Log /tmp/omc-rtest-adrpo/parser/log-CheckSourcesForTabs.mos

so, we can leave it like this with no issues.

comment:3 by Adrian Pop, 13 years ago

See SCM commit tab.

Note: See TracTickets for help on using tickets.