pyret-lang icon indicating copy to clipboard operation
pyret-lang copied to clipboard

First mutable update binding is evaluated twice when type checking is turned on

Open molenzwiebel opened this issue 3 years ago • 0 comments

Example:

var calls = 0

fun get() block:
  calls := calls + 1
  0
end

data A:
  a(ref x :: Number)
end

a(1)!{ x: get() }

print("Total calls: " + to-string(calls))

When the type checker is turned off, this will print Total calls: 1. If the type checker is turned on however, it will print Total calls: 2. This only happens with the first binding in a mutable update (subsequent bindings are only evaluated once), and does not happen with object extends.

molenzwiebel avatar Jun 28 '21 10:06 molenzwiebel