Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#3255 closed defect (fixed)

getComponentAnnotations should merge the constrainedby annotation with the component annotation

Reported by: Adeel Asghar Owned by: Adrian Pop
Priority: high Milestone: 1.9.4
Component: Parser Version: trunk
Keywords: Cc: Martin Sjölund

Description

getComponentAnnotations returns empty annotation for the component if constrainedby is used.

Attachments (2)

C.mo (171 bytes ) - added by Adeel Asghar 10 years ago.
C.mos (84 bytes ) - added by Adeel Asghar 10 years ago.

Download all attachments as: .zip

Change History (10)

by Adeel Asghar, 10 years ago

Attachment: C.mo added

by Adeel Asghar, 10 years ago

Attachment: C.mos added

comment:1 by Adrian Pop, 10 years ago

Cc: Martin Sjölund added
Component: Interactive EnvironmentParser

Hmm, there seems to be an issue with the way we parse Modelica grammar here:

element :
  import_clause | extends_clause | 
  [ redeclare ] [ final ] [ inner ] [ outer ]
  ( ( class_definition | component_clause) | 
    replaceable ( class_definition | component_clause) [constraining_clause comment])

component_clause:
type_prefix type_specifier [ array_subscripts ] component_list

component_list :
  component_declaration { "," component_declaration }

component_declaration :
  declaration [ condition_attribute ] comment

Seems that the annotation end up as the comment for the constrainedby clause.

loadString("model M
  type N = Real;
  replaceable N n1 constrainedby Real annotation(choicesAllMatching=true,Placement(visible = true, transformation(origin = {-30, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end M;");
getErrorString();
getComponentAnnotations(M);
getErrorString();

comment:2 by Adrian Pop, 10 years ago

Seems that Modelica allows you to write:

replaceable T1 a[2] annotation(1), b[3] annotation(2), c[4] annotation(3) constrainedby T2 annotation(4);

which is a bit weird as constrainedby T2 should be applied to all the components.

Version 0, edited 10 years ago by Adrian Pop (next)

comment:3 by Adrian Pop, 10 years ago

I opened a ticket on MA: m:#1689 and we'll see where that gets us.

comment:4 by Adrian Pop, 10 years ago

Summary: getComponentAnnotations fails when constrainedby is usedgetComponentAnnotations should merge the constrainedby annotation with the component annotation

comment:5 by Adrian Pop, 10 years ago

This ticket might also apply for short class definitions:

redeclare T = T1 annotation(1) constrainedby T2 annotation(2);

comment:6 by Adrian Pop, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r25478 for components. Reopen if we need it also for short class definitions.

comment:7 by Dietmar Winkler, 9 years ago

Milestone: Futurepre1.9.4

It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.

comment:8 by Martin Sjölund, 7 years ago

Milestone: pre1.9.41.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.