Opened 11 years ago

Closed 11 years ago

#2662 closed defect (fixed)

Handle self-referencing function calls

Reported by: Martin Sjölund Owned by: somebody
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc: Per Östlund

Description

The following goes into a stack overflow.

package Base

partial function parent
  input Real a;
algorithm
  g(a);
end parent;

end Base;

function g
  extends Base.parent;
end g;

model M
  Real r = g(time,recurse=true);
end M;

Change History (6)

comment:1 by Martin Sjölund, 11 years ago

I guess I will have to have a look if you don't have time for it, Per.

in reply to:  1 comment:2 by Per Östlund, 11 years ago

Replying to sjoelund.se:

I guess I will have to have a look if you don't have time for it, Per.

Depends on how important it is to fix ;) If you want it fixed quickly it's probably best if you look at it yourself.

comment:3 by Martin Sjölund, 11 years ago

I have work-arounds I can use. The purpose is to write much cooler and optimised code in the bootstrapped compiler if it would work...

comment:4 by Martin Sjölund, 11 years ago

The following also stack overflows... +d=scodeInst says Error: Expected Base.parent to be a class, but found function instead.

package Base

partial function parent
  input Real a;
  replaceable function self = parent;
algorithm
  self(a);
end parent;

end Base;

function g
  extends Base.parent;
  redeclare function self = g;
end g;

model M
equation
  g(time);
end M;

in reply to:  4 comment:5 by Per Östlund, 11 years ago

Replying to sjoelund.se:

The following also stack overflows... +d=scodeInst says Error: Expected Base.parent to be a class, but found function instead.

Fixed in r20099. scodeInst now gets a stack overflow instead, probably because the redeclare isn't handled.

comment:6 by Per Östlund, 11 years ago

Resolution: fixed
Status: newclosed

Fixed in r20133.

Note: See TracTickets for help on using tickets.