-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of record bindings #10820
Conversation
4be2d31
to
7911d6e
Compare
- Don't evaluate non-structural parameters. - Use `tryEvalExp` instead of `evalExp` when trying to evaluate record bindings, to hide any eventual error messages since failure is ok. - Improve the function inlining by merging the inlining of record constructors with the inlining of normal function calls, and allowing forced inlining regardless of annotation. Fixes OpenModelica#10812
This has not yet gone through the master regression tests (there is a bit of queue unfortunately), but I think it broke some Buildings models. You can check the The issue is around this algorithm vol.state_start := if size({vol.X_start[1:vol.Medium.nXi]}, 1) == 2 then
Buildings.Examples.Tutorial.Boiler.System1.vol.Medium.ThermodynamicState(vol.p_start, vol.T_start, {vol.X_start[1]}) else
Buildings.Examples.Tutorial.Boiler.System1.vol.Medium.ThermodynamicState(vol.p_start, vol.T_start, {vol.X_start[1], 1.0 - vol.X_start[1]}); Specifically, the problem is the The following model, which is as close as possible I can make it to the issue without model Test
Real a[2] = {time + 1, time + 2};
Real b[1,2];
Integer i;
algorithm
i := if time < 1 then 2 else 3;
b := {a[i-1:i]};
end Test; Is there anything that you can see that might suggest that the expression
|
- Temporarily disable inlining of normal functions when splitting record bindings, since it causes issues at the moment.
@mahge: I disabled the part that seems to be causing the issue in #10842. It seems inlining normal functions is causing some issue in this case, it creates the if-expression you mentioned which it then fails to evaluate and moves it to an initial equation because it can't split it. I don't know what's going wrong, maybe the inlining is incorrect somehow. But that part isn't actually necessary for fixing the issue so I disabled it for now until I have time to take a better look at it. |
- Temporarily disable inlining of normal functions when splitting record bindings, since it causes issues at the moment.
Thanks. Hopefully, this makes it to tonight's nightly build and regression test so we can see the effect tomorrow. The PR build for #10842 was failing due to the |
- Temporarily disable inlining of normal functions when splitting record bindings, since it causes issues at the moment.
- Fix constant evaluation of `size` by evaluating the dimension size(s) instead of just returning whatever `Dimension.sizeExp` returns, which was causing the regressions from OpenModelica#10820. - Reactivate inlining of normal functions when trying to split record bindings.
#10844 should fix the issues that occured due to the inlining. The issue was that |
- Fix constant evaluation of `size` by evaluating the dimension size(s) instead of just returning whatever `Dimension.sizeExp` returns, which was causing the regressions from #10820. - Reactivate inlining of normal functions when trying to split record bindings.
tryEvalExp
instead ofevalExp
when trying to evaluate record bindings, to hide any eventual error messages since failure is ok.Fixes #10812