"this" not protected in lambdas in tail-recursive functions #4684
Labels
during 4: bad execution of correct program
A bug in the Dafny compiler that causes a correct Dafny program to execute incorrectly
kind: bug
Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
part: code-generation
Support for transpiling Dafny to another language. If relevant, add a `lang:` tag
priority: next
Will consider working on this after in progress work is done
Dafny version
4.3.0
Code to produce this issue
Command to run and resulting output
What happened?
Both the non-tail-recursive function and the tail-recursive one should output
20
. However, the tail-recursive one outputs0
. This is a problem for the C#, JavaScript, Go, and Python backends. The Java backend emits malformed code.The problem is that, for tail recursive instance function,
this
(which the target languages generally don't allow to be modified) is placed in a local variable,_this
. This variable needs to be protected wheninLetExprBody
istrue
, just like in theIdentifierExpr
case.What type of operating system are you experiencing the problem on?
Mac
The text was updated successfully, but these errors were encountered: