Opened 11 years ago
Closed 11 years ago
#2729 closed defect (fixed)
Short class definition for functions without parameter
Reported by: | Martin Sjölund | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 1.9.1 |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: |
Description
The following works fine if p is a parameter (same pattern used by gravityAcceleration):
function f input Real x; input Real r; output Real o := x+r; end f; model M Real p = 2.0; function g = f(r=p); Real x = g(1.0); end M;
Why? The error-message is horrible.
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Thinking on it a bit more I realized that both of the above points are already an issue even without my fixes, so I've committed them anyway. I'll close this ticket since it's fixed, but will open a new one for the issues I outlined above.
Note:
See TracTickets
for help on using tickets.
The issue can be fixed for this particular model by making sure that the evaluation of function parameter default bindings doesn't try to evaluate crefs which are not defined in the function (i.e. p in this case). Doing so is rather trivial since we know what components a function has.
This has two problems though:
f
would have a function parameter calledp
, then it would be used when evaluatingr=p
instead.So fixing this issue the easy way will unfortunately mean that functions can silently be incorrectly evaluated, giving the wrong result. And fixing it the hard way is hard...