Closed DanGooding closed 2 years ago
Ha, very strange -- I am looking into it soon.
Thanks for the report! I found the bug and it is fixed in the latest dev
branch. The example program was very helpful.
Thats great, thanks for the quick response!
Hello, I'm enjoying using Koka, but have come across a slightly bizarre bug.
In the following example, the expression
( resume(True) || resume(False) ) : bool
does not short-circuit, whereas the similar expressions(resume(True) : bool) || resume(False)
andresume(True) || False || resume(False)
do short-circuit.When using AND instead (and swapping True/False) as in
resume(False) && resume(True)
the expression does short-circuit! (only evaluating the firstresume
). Could this somehow be to do with the overloading of||
? (whereas&&
is not overloaded)?Here's a full example:
This example has the following output:
both
satisfiable-no-short-circuit()
andsatisfiable-short-circuit()
returnTrue
, but the former evaluates both calls toresume
, whist the latter only evaluates the first (resume(True)
).This issue occurs for me in Koka version
2.4.0
(I haven't tried it in other versions).For completeness, here are a few more working and non-working cases I found:
No short-circuit:
False || resume(True) || resume(False)
fun k(b) { resume(b) }; ( (k(True) || k(False)) : bool )
Short-circuit:
(resume(True) : bool) || resume(False)
resume(True) || (resume(False) : bool)
resume(True) || False || resume(False)
resume(True) || resume(False) || False
(False || resume(True)) || resume(False)
resume(True) || (False || resume(False))
fun k(b) : <console> bool { resume(b) }; ( k(True) || k(False) )