#5657 closed defect (duplicate)

Assignment size checks in instance function evaluation

Reported by: Zimon Kuhs Owned by: Zimon Kuhs
Priority: minor Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:

Description

Compiling the model

        function f
            input Integer n;
            output Real[n] y;
        algorithm
            y := zeros(0);
        end f;
        constant Real[:] p1 = f(1);

yields:

Exception caught while scalarizing component'p1'org.jmodelica.util.exceptions.InternalCompilerError: Exception caught while scalarizing component'p1'.  Internally the InternalCompileError is caused by a NullPointerException being thrown from 
	at org.jmodelica.modelica.compiler.FVariable.createScalarFVariable(FVariable.java:959)
	at org.jmodelica.modelica.compiler.FVariable.doScalarize(FVariable.java:922)
	at org.jmodelica.modelica.compiler.FVariable.scalarize(FVariable.java:909)

The problem is that the assignment y := zeros(0) is always an empty array, whereas y is sized according to the input n. This should yield an error pointing out the array size mismatch instead.

Change History (1)

comment:1 Changed 16 months ago by Zimon Kuhs

Resolution: duplicate
Status: assignedclosed
Note: See TracTickets for help on using tickets.