Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#3255 closed defect (fixed)

getComponentAnnotations should merge the constrainedby annotation with the component annotation

Reported by: adeas31 Owned by: adrpo
Priority: high Milestone: 1.9.4
Component: Parser Version: trunk
Keywords: Cc: sjoelund.se

Description

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

Attachments (2)

C.mo (171 bytes) - added by adeas31 9 years ago.
C.mos (84 bytes) - added by adeas31 9 years ago.

Download all attachments as: .zip

Change History (10)

Changed 9 years ago by adeas31

Changed 9 years ago by adeas31

comment:1 Changed 9 years ago by adrpo

  • Cc sjoelund.se added
  • Component changed from Interactive Environment to Parser

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 Changed 9 years ago by adrpo

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.

Last edited 9 years ago by adrpo (previous) (diff)

comment:3 Changed 9 years ago by adrpo

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

comment:4 Changed 9 years ago by adrpo

  • Summary changed from getComponentAnnotations fails when constrainedby is used to getComponentAnnotations should merge the constrainedby annotation with the component annotation

comment:5 Changed 9 years ago by adrpo

This ticket might also apply for short class definitions:

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

comment:6 Changed 9 years ago by adrpo

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

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

comment:7 Changed 8 years ago by dietmarw

  • Milestone changed from Future to pre1.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 Changed 6 years ago by sjoelund.se

  • Milestone changed from pre1.9.4 to 1.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.