Element referencing namespace bug

Hi guys,

Sorry to (probably) be the first one to report a bug for 0.8.2 :frowning:

I am trying to create a reference to another element with the same name, and it doesn’t really work (yet?). Consider this model:

package Package {
    part thePart;
    action theAction;
}

Python script:

import syside

model, _ = syside.load_model(['model.sysml'])
with model.documents[-1].lock() as doc:
    root_node = doc.root_node
    package: syside.Package = root_node.children.elements[0]

    part, action = package.children.elements
    assert isinstance(part, syside.PartUsage)

    _, action_ref = part.children.append(syside.OwningMembership, syside.ActionUsage)
    action_ref.declared_name = action.name
    action_ref.heritage.append(syside.ReferenceSubsetting, action)

    printer_config = syside.PrinterConfig(line_width=80, tab_width=2)
    printer = syside.ModelPrinter.sysml()
    output = syside.pprint(root_node, printer, printer_config)
    print(output)

    with open('model2.sysml', 'wb') as fp:
        fp.write(output.encode('utf-8'))

syside.load_model(['model2.sysml'])

This is the created textual notation:

package Package {
  part thePart { action theAction ::> $::theAction; }
  action theAction;
}

Leading to the error when loading this model:

model2.sysml:2:42: error (reference-error): No Feature named 'theAction' found.

Instead of $:: it should be Package::.
It is already an improvement over 0.8.1 though, where no qualified path was added at all and therefore the names were actually duplicate.

Greetings,
Jasper

Thanks for the report. Fixed for the next release.

1 Like