Opened 4 years ago
Last modified 3 years ago
#6213 accepted defect
Lookup in wrong scope when redeclaring function field in a function
Reported by: | Martin Sjölund | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | New Instantiation | Version: | v1.17.0-dev |
Keywords: | Cc: |
Description
Modelica_LinearSystems2.Controller.Examples.DiscretizationSeries has some code with the same error as:
record R Real x[:]; end R; function f input Integer n; output R r(redeclare Real x[n]); end f; model M Real x[:] = f(3); end M;
Change History (5)
comment:1 by , 4 years ago
Status: | new → accepted |
---|
comment:2 by , 4 years ago
Component: | Frontend → New Instantiation |
---|
I guess after 1.17.0 we can start to use "Frontend" again. At least, let's wait until we are sure that we can transition to the NF safely.
comment:3 by , 4 years ago
Fixed in PR 6938, but it still doesn't work properly.
The lookup now works as it should but the type of the function call will be record R(Real[n])
, i.e. we apply the redeclare correctly but don't evaluate n
in the return type. The issue is that complex types are represented by an instance node, so we can't currently change a complex output type without also affecting the type of all other calls of that function. We need to either clone the instance nodes in complex types when typing a function call, which I'm not sure is a good idea, or change how we represent types in this situation.
comment:4 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
The issue is that we don't save the scope that the dimension are declared in, so when we later try to instantiate it we don't know it came from a redeclare and should actually be looked up inside
f
. We need to save the scope in the same way that we currently handle bindings and use that instead when instantiating dimensions.