Opened 3 years ago

Last modified 22 months ago

#5305 assigned defect

Function type calculation requires re-calculation

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

Description

Exposed when updating to JastAdd 2.2.2 (r9674).

The NTA type attribute FunctionType for InstClassDecl requires re-calculation in order to work with InstPartialFunctionCalls.

If the workaround in InstPartialFunctionCall is removed the following tests break:

* ModelicaFlatTree.EvaluationTests.Functional5
* ModelicaFlatTree.EvaluationTests.Functional6

The workaround introduced in r9674:

    public <T extends CommonVariableDecl> ArrayList<T> InstPartialFunctionCall.filterPartialInputs(ArrayList<T> decls) {
        myInstCallable().actualInstClassDecl().getFunctionType_computed = false;
        return super.filterPartialInputs(decls);
    }

This is because when InstPartialFunctionCall#myCallInputs() is calculated the filtered inputs of the partial function call fullFunc(x3=2) include x2 and x3 when they should only include x3. x2 is included because filtering is performed by removing all inputs of the calculated type from all the aggregated inputs of the fully expanded function (fullFunc extends two other functions), and if the type from #myCallInputs() isn't recalculated its type is:

((Real y1) = EvaluationTests.Functional5.fullFunc(Real x1))

whereas the type if recalculated is:

((Real y1) = EvaluationTests.Functional5.fullFunc(Real x1, Real x2))

The former case will cause a NullPointerException since values will be attempted to be assigned to both x2 and x3 when the actual partial function call only has one value.

The error is likely related to the fact that the partial function call is evaluated directly after another partial function call from the same function call usePartFunc(fullFunc(x2=2, x3=1), fullFunc(x3=2), 3).

Change History (2)

comment:1 Changed 3 years ago by Zimon Kuhs

Owner: changed from Jesper Mattsson to Zimon Kuhs
Status: newassigned

comment:2 Changed 22 months ago by Jesper Mattsson

Owner: changed from Zimon Kuhs to Jonathan Kämpe
Note: See TracTickets for help on using tickets.