Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

COMPILER BUG

COMPILER BUG

Hi. I was trying out the different Modelica array constructs and found this shown then i tried to simulate.

Code:

"[<interactive>:8:3-8:31:writable] Error: Got type mismatch error, but matching types Real[2, 2].

This is a ***COMPILER BUG***, please report it to https://trac.openmodelica.org/OpenModelica.
Error: Error occurred while flattening model ArrayFunctions5
"

Here is the model which led to the error.

Code:

model ArrayFunctions5 "Matrix and Vector Algebra Functions"

  Real[2,2] A = [1,2;3,4];
  Real[2,2] AT;
  Real[2] v1 = {2,1},v2 = {3,2};
  Real[2,2] oProd;
equation
  AT = transpose(A);
  oProd = outerProduct(v1, v2);
end ArrayFunctions5;

Is this issue known or should i report it to the trac?

Re: COMPILER BUG

Thank you for reporting this. It was quite easy to fix, so I've already fixed it. The fix should be in the next nightly build tomorrow.

Re: COMPILER BUG

Can you tell me what caused this error?

Re: COMPILER BUG

Sanjay_Kamath wrote:

Can you tell me what caused this error?

The issue was that outerProduct was incorrectly typed in this case. Because of how the compiler is constructed this led to a situation where the compiler thought the types on both sides of the equation where different even though they were the same. Such cases are always compiler bugs, hence the error message.

Re: COMPILER BUG

thanks for the info.

But i found this error only when i gave

Code:

oProd = outerProduct(v1, v2);

It didnt come when i used

Code:

oProd = outerProduct({2,1},{3,2});

Why so?

Re: COMPILER BUG

Because the issue was caused by the compiler not knowing the type of the component references v1 and v2 at one point, and this caused it to assign the wrong type later on. {2, 1} and {3, 2} are array literals and much easier to type.

Re: COMPILER BUG

Thanks current/smile

There are 0 guests and 0 other users also viewing this topic
You are here: