Opened 14 years ago

Last modified 14 years ago

#1198 closed defect (fixed)

Calling derived functions fails

Reported by: sjoelund.se Owned by: sjoelund.se
Priority: high Milestone:
Component: Version:
Keywords: Cc: sjoelund.se, AlexeyLebedev

Description

{{{function f
output Real r = 2;
end f;

model M

function f2 = f;
constant Real r = f2();

end M;}}}

Change History (5)

comment:1 Changed 14 years ago by AlexeyLebedev

If I remove the line
Util.setStatefulBoolean(inState,true);

from the first case of the function lookupClass2, it does not break anything in the testsuite, and I get the following result for this example:
{{{Det går inte att hitta sökvägen.
Det går inte att hitta sökvägen.
function M.f2
output Real r = 2.0;
end M.f2;
fclass M
constant Real r = M.f2();
end M;
#- Error building simulation code. Ceval.compileModel failed.

#- Error building simulation code. Ceval.compileModel failed.}}}

I'm not sure about some things, though:

1) OMC cannot do constant evaluation of f2(). Should I work on it?

2) During instantiation, the cache contains environment $global.M.f . Is it normal or should it be fixed? There is no class M.f, but I'm not sure how cache is supposed to work.

3) Do you know where the "Det går inte att hitta sökvägen." messages come from? (If I understand correctly, it means "Can't find search path".) They are clearly not from the compiler - it only contains English messages.

comment:2 Changed 14 years ago by AlexeyLebedev

If one keeps setStatefulBoolean in lookupClass2, but replaces env by cenv in the line
(cache,_,ih,_,dae,_,ty,_,_,_) = instClass(cache,env,ih,UnitAbsynBuilder.emptyInstStore(), mod2, Prefix.NOPRE(), Connect.emptySet, c, {}, true, INNER_CALL(), ConnectionGraph.EMPTY);

in the second case of Inst.implicitFunctionTypeInstantiation, it also fixes lookup problem and does not break anything in the testsuite.

Still, constant eveluation of f2() fails, and there are "Det går inte att hitta sökvägen" messages.

comment:3 Changed 14 years ago by AlexeyLebedev

Added a case for derived functions without modifications to cevalUserFunc in revision 5507. Now this case works fine.

comment:4 Changed 14 years ago by sjoelund.se

Was there a testcase added for this bug?

comment:5 Changed 14 years ago by AlexeyLebedev

I have not added a testcase.

Note: See TracTickets for help on using tickets.