Opened 12 years ago
Closed 12 years ago
#1980 closed defect (invalid)
SCodeFlatten fails to rename imports
Reported by: | sjoelund.se | Owned by: | perost |
---|---|---|---|
Priority: | high | Milestone: | 1.9.0 |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: |
Description (last modified by perost)
SCodeFlatten fails to rename imports that are part of a path
package N import N.X.x; package X Real x = 1.0; end X; end N; model M import N.X.x; Real r1 = N.x; Real r2 = x; end M;
Change History (8)
comment:1 Changed 12 years ago by perost
- Description modified (diff)
comment:2 Changed 12 years ago by perost
This model actually seems to work as intended. It only looked like it was failing because of using r instead of x at first, and bad error reporting for missing imports (see #1977). You'll have to submit a better model :)
comment:3 Changed 12 years ago by sjoelund.se
These are lots of fun:
package N import Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end N; model M import Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; // Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r1 = N.simpleWaterConstants; // Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r2 = simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r3 = Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end M;
comment:4 Changed 12 years ago by perost
saveTotalSCode on M with the latest MSL 3.2.1 and a clean trunk gives:
model M Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r1 = .Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r2 = .Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r3 = Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end M;
Seems correct to me, and the model instantiates fine it seems.
comment:5 Changed 12 years ago by sjoelund.se
With saveTotalSCode I get:
model M Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r1 = N.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r2 = simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r3 = Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end M;
I guess I will try make clean.
comment:6 Changed 12 years ago by sjoelund.se
Nope. Make clean still gives me the same output (which is different from yours).
comment:7 Changed 12 years ago by adrpo
I get the same output as Per for
adrpo@testone:~/om/build/bin$ cat m.mos loadModel(Modelica); getErrorString(); loadFile("m.mo"); getErrorString(); saveTotalSCode("m-total.mo", M); getErrorString(); readFile("m-total.mo"); getErrorString();
File m.mo
adrpo@testone:~/om/build/bin$ cat m.mo package N import Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end N; model M import Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r1 = N.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r2 = simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r3 = Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end M;
result:
adrpo@testone:~/om/build/bin$ ./omc m.mos | grep -5 "model M" package N end N; model M Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r1 = .Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r2 = .Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; Modelica.Media.Water.ConstantPropertyLiquidWater.FluidConstants[1] r3 = Modelica.Media.Water.ConstantPropertyLiquidWater.simpleWaterConstants; end M;
comment:8 Changed 12 years ago by sjoelund.se
- Resolution set to invalid
- Status changed from new to closed
Ok. rm -rf Compiler works, make clean did not. Go figure, it works in trunk so I'll just close this.
Renamed component r to x so that the model is valid.