Opened 9 years ago

Closed 3 years ago

#3058 closed defect (fixed)

Type mismatch in functions with an if clause

Reported by: wbraun Owned by: somebody
Priority: high Milestone: 1.16.0
Component: New Instantiation Version: trunk
Keywords: Cc:

Description

Following model results into a Type mismatch, which is actually not there.

loadString("
function f
  input Real A[:,size(A, 1)];
  output Real H[size(A,1),size(A,2)];

protected
  Integer n=size(A,1);

algorithm
 print(\"Size A \" + String(size(A,1)) + \"\\n\");
 if size(A,1) == 0 then
   H := fill(0,0,0); // <= Shouldn't evaluated
 end if;
 for i in 1:n loop
   for j in 1:n loop
     H[i, j] := H[i,j] + 1.0;
   end for;
  end for;
end f;

model test
  Real msr_mat[2, 2];
equation
  msr_mat  = f({{1,0},{0,1}});
end test;
");
getErrorString();
simulate(test);
getErrorString();

=>

Error: Type mismatch in assignment in H := {} of Real[size(A, 1), size(A, 2)] := Integer[0, 0]

The Modelica function Modelica.Math.Matrices.cholesky is also effected by this bug.

Change History (1)

comment:1 Changed 3 years ago by perost

  • Component changed from Frontend to New Instantiation
  • Milestone changed from Future to 1.16.0
  • Resolution set to fixed
  • Status changed from new to closed

Works fine in the new frontend.

Note: See TracTickets for help on using tickets.