Opened 9 years ago

Closed 9 years ago

#3380 closed defect (fixed)

Save bug with replaceable

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

Description (last modified by Martin Sjölund)

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 by Martin Sjölund, 9 years ago

Description: modified (diff)

comment:2 by Martin Sjölund, 9 years ago

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.

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

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 by Martin Sjölund, 9 years ago

Owner: changed from Adeel Asghar to Martin Sjölund
Status: newaccepted

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 by Martin Sjölund, 9 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in git.

Last edited 9 years ago by Martin Sjölund (previous) (diff)

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

Resolution: fixed
Status: closedreopened

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 by Martin Sjölund, 9 years ago

Owner: changed from Martin Sjölund to Adeel Asghar
Status: reopenedassigned

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 by Adeel Asghar, 9 years ago

Resolution: fixed
Status: assignedclosed

Fixed in c183a8/OMEdit.

Note: See TracTickets for help on using tickets.