Opened 9 years ago

Last modified 9 years ago

#3725 accepted defect

loadString merge=true create duplicate elements

Reported by: Adeel Asghar Owned by: Adrian Pop
Priority: high Milestone: Future
Component: Interactive Environment Version: v1.9.4-dev-nightly
Keywords: Cc:

Description

Run the attached script.

Attachments (1)

script.mos (627 bytes ) - added by Adeel Asghar 9 years ago.

Download all attachments as: .zip

Change History (6)

by Adeel Asghar, 9 years ago

Attachment: script.mos added

comment:1 by Adrian Pop, 9 years ago

Status: newaccepted

comment:2 by Adrian Pop, 9 years ago

The problem in the script above does this:

setSourceFile(Test, "Test");

If you remove it, everything is fine.

The merge is implemented like:

  1. get the old class and get its filename
  2. remove *all* elements which have the same filename
  3. merge with the contents of the new class

In this case we do:

  1. get the old class and get its filename
    Test in this case was set via setSourceFile
  2. remove *all* elements which have the same filename
    Removes nothing because all elements have filename
    <interactive> and not Test

So basically what happens is that we duplicate the class contents and then do union which keeps both parameter Integer N = 2; and Integer N = 2; because they are different.

I'll see how I can fix this.

comment:3 by Adeel Asghar, 9 years ago

so you mean setSourceFile(Test, "Test"); doesn't set filename for all elements?

comment:4 by Adrian Pop, 9 years ago

No. Just for that class, the elements inside the class are not affected.
I think it should behave like that anyway as if it would set all the elements then you might have issues with the packages loaded inside other packages.

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

It should set it for all non-class elements (or the file merging should assume variables, etc are part of the class since they can't be part of another file).

Note: See TracTickets for help on using tickets.