Opened 11 years ago

Closed 11 years ago

#2418 closed defect (fixed)

component modification references wrong scope

Reported by: Bill Janssen Owned by: probably noone
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: AVM Cc:

Description

When I run this model

package test4

  model foo
    replaceable type paramType = Real;
    input paramType u;
    output paramType y;
  equation
    y = sin(u);
  end foo;

  model bar
    parameter Real x[:,2] = [0, 1];
    foo bletch(u=x, redeclare type paramType = Real[size(x,1),2]);
  end bar;
  
end test4;

with 1.9.0RC1, I get this:

% omc +s +i=test4.bar /tmp/test4.mo
Error processing file: /tmp/test4.mo
[/private/tmp/test4.mo:13:31-13:65:writable] Error: Variable x not found in scope test4.foo.
[/private/tmp/test4.mo:13:16-13:19:writable] Error: Variable x not found in scope test4.foo.
Error: Error occurred while flattening model test4.bar

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!
% 

However, Dymola accepts it.

It looks as if the "x" in the modifications is being dereferenced to refer to foo.x, not the proper bar.x. In fact, if I add an "x" to foo, thusly

package test5

  model foo
    replaceable type paramType = Real;
    input paramType u;
    output paramType y;
    paramType x;
  equation
    y = sin(u);
  end foo;

  model bar
    parameter Real x[:,2] = [0, 1];
    foo bletch(x=x, redeclare type paramType = Real[size(x,1),2]);
  end bar;
  
end test5;

I get the expected flattened form:

% omc +s +i=test5.bar /tmp/test5.mo
class test5.bar
  parameter Real x[1,1] = 0.0;
  parameter Real x[1,2] = 1.0;
  input Real bletch.u[1,1];
  input Real bletch.u[1,2];
  output Real bletch.y[1,1];
  output Real bletch.y[1,2];
  Real bletch.x[1,1];
  Real bletch.x[1,2];
equation
  bletch.x = {{x[1,1], x[1,2]}};
  bletch.y[1,1] = sin(bletch.u[1,1]);
  bletch.y[1,2] = sin(bletch.u[1,2]);
end test5.bar;

Change History (1)

comment:1 by Adrian Pop, 11 years ago

Component: BackendFrontend
Resolution: fixed
Status: newclosed

Fixed in r17650.

Note: See TracTickets for help on using tickets.