Uh oh!
There was an error while loading. Please reload this page.
feat: add disable short-circuiting option to compiler - #847
Conversation
lvliangxiong
commented
Sep 27, 2025
I just fix the code according to the check result. It'll be good now. |
antonmedv
commented
Sep 29, 2025
Nice! Let me review this more carefully. |
We could implement this with less core changes if we follow your example here. My suggestion is the following (Go Playground working example): // DisableShortCircuit turns short circuiting behaviour off in `&&`, `and`, `||`, and `or` boolean operators.funcDisableShortCircuit() expr.Option {
returnfunc(c*conf.Config) {
expr.Function("OR", func(params...any) (any, error) {
returnparams[0].(bool) ||params[1].(bool), nil
}, func(a, bbool) bool { returntrue })(c)
expr.Function("AND", func(params...any) (any, error) {
returnparams[0].(bool) &¶ms[1].(bool), nil
}, func(a, bbool) bool { returntrue })(c)
expr.Operator("or", "OR")(c)
expr.Operator("||", "OR")(c)
expr.Operator("and", "AND")(c)
expr.Operator("&&", "AND")(c)
}
}This way we will not need any changes to vm and compiler packages and the core language remains smaller. |
lvliangxiong
commented
Oct 26, 2025
I also considered this solution at first glance. However, after spending some time investigating the implementation, I realized this more intuitive solution might potentially conflict with or be overridden by other patch/optimization features. I'm not sure if my concerns are unnecessary, so I've implemented this in the compiler & vm package, which I find easier to understand and might be more robust without bugs. On the other hand, I give it a try and find something interesting. Since I don't have much time to figure out every detail of the implementation, I'm not sure if this operator overloading solution has other hidden bugs or limitations, or we can solve this by some other tricks? What do you think about this? Looking forward to your reply. |
antonmedv
commented
Oct 26, 2025
I think proposal solution in this poor request is proper. Disable short circuit should generate different bytecode. |
lvliangxiong
commented
Nov 13, 2025
Any progress here? Let me know if I can help. |
Uh oh!
There was an error while loading. Please reload this page.
#831