Opened 15 years ago
Last modified 15 years ago
#1198 closed defect (fixed)
Calling derived functions fails
Reported by: | Martin Sjölund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | Martin Sjölund, 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 by , 15 years ago
comment:2 by , 15 years ago
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 by , 15 years ago
Added a case for derived functions without modifications to cevalUserFunc in revision 5507. Now this case works fine.
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.
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.