Opened 9 years ago

Closed 9 years ago

#3380 closed defect (fixed)

Save bug with replaceable

Reported by: Arno_Epsilon <acolleoni@…> Owned by: adeas31
Priority: blocker Milestone: 1.9.3
Component: OMEdit Version: trunk
Keywords: Replaceable, Package Cc:

Description (last modified by sjoelund.se)

I created a model with a replaceable function inside.
When i try to save this model (included in a package with multiple files saving option), the .mo created delete the line "replaceable function ..." in the model.

Here is an example, to be placed in a package with multiple file saving option:

package Test
  function Functiona
    output Real y;
  algorithm
    y := 1;
  end Functiona;

  model Testa
    replaceable function func = Functiona;
    Real y;
  equation
    y = Functiona();
  end Testa;
end Test;

Change History (8)

comment:1 Changed 9 years ago by sjoelund.se

  • Description modified (diff)

comment:2 follow-up: Changed 9 years ago by sjoelund.se

OMEdit issues the following commands:

setSourceFile(Test, "/home/marsj/tmp/Test/package.mo")
true

save(Test)
true

setSourceFile(Test.Functiona, "/home/marsj/tmp/Test/Functiona.mo")
true

save(Test.Functiona)
true

setSourceFile(Test.Testa, "/home/marsj/tmp/Test/Testa.mo")
true

save(Test.Testa)
true

setSourceFile(Test.Testa.func, "/home/marsj/tmp/Test/func.mo")
true

save(Test.Testa.func)
false

No error-message is generated for the failed save() command.

comment:3 in reply to: ↑ 2 Changed 9 years ago by Arno_Epsilon <acolleoni@…>

Replying to sjoelund.se:

OMEdit issues the following commands:

setSourceFile(Test, "/home/marsj/tmp/Test/package.mo")
true

save(Test)
true

setSourceFile(Test.Functiona, "/home/marsj/tmp/Test/Functiona.mo")
true

save(Test.Functiona)
true

setSourceFile(Test.Testa, "/home/marsj/tmp/Test/Testa.mo")
true

save(Test.Testa)
true

setSourceFile(Test.Testa.func, "/home/marsj/tmp/Test/func.mo")
true

save(Test.Testa.func)
false

No error-message is generated for the failed save() command.

Hello, and thank you for treating my problem.
I am not saying that the save fails. The save works but when i look inside Testa.mo, the line "replaceable function func = Functiona;" disappears. Hence when i try to re-load my package, as the replaceable line disapeared, i cant redeclare the function anymore.

I see that the model runs even after deleting the line but it is a mistake from myself since Testa should use func() and not Functiona() :

  model Testa
    replaceable function func = Functiona;
    Real y;
  equation
    y = func();
  end Testa;

In this configuration, the deletion of the second line (with replaceable function func = Functiona;) makes the model bug.

comment:4 Changed 9 years ago by sjoelund.se

  • Owner changed from adeas31 to sjoelund.se
  • Status changed from new to accepted

I know, just added the log to see which command was going wrong. OMEdit expects the file Test.Testa.func to be created, but it is not.

comment:5 follow-up: Changed 9 years ago by sjoelund.se

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in git.

Last edited 9 years ago by sjoelund.se (previous) (diff)

comment:6 in reply to: ↑ 5 Changed 9 years ago by Arno_Epsilon <acolleoni@…>

  • Resolution fixed deleted
  • Status changed from closed to reopened

Replying to sjoelund.se:

Fixed in git.

I tried the today nightly build.
Test.Testa.func.mo is now created although it should not.
The line with replaceable in Testa disappears again.
And I have now some issue when saving the package:

[1] 09:45:39 Grammaire Erreur
[U:/ETUDES/MODELICA/Tests/Test/func.mo: 3:1-3:26]: Expected the package to have within Test; but got within Test.Testa;.

[2] 09:45:39 Ecriture Erreur
Failed to load package Test () using MODELICAPATH U:\ETUDES\MODELICA\Tests\;C:/OpenModelica1.9.3Nightly/lib/omlibrary.

comment:7 Changed 9 years ago by sjoelund.se

  • Owner changed from sjoelund.se to adeas31
  • Status changed from reopened to assigned

Adeel: OMEdit sets the wrong source file for the function. Also, prefixes are stripped from stored definitions. So OMEdit should not try to save the element in a separate file.

comment:8 Changed 9 years ago by adeas31

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in c183a8/OMEdit.

Note: See TracTickets for help on using tickets.