gobra icon indicating copy to clipboard operation
gobra copied to clipboard

Ghost Erasure produces wrong Go Code

Open ArquintL opened this issue 3 years ago • 2 comments

The binary operation involving a function call in the following Gobra code is ghost erased to foo(n - 1) + 1 instead of foo(n - 1):

func foo(n int) (ghost res int) {
    if (n <= 0) {
        return 0
    } else {
        res = foo(n-1) + 1
    }
}

ArquintL avatar Jan 28 '21 13:01 ArquintL

Also, the following method in example infinite_list.gobra is incorrectly printed.

  • Gobra code
requires infList(ptr)
requires n >= 0
pure func nth(ptr *node, n int) (r int) {
  return unfolding infList(ptr) in n == 0 ? ptr.value : nth(ptr.next, n-1)
}
  • Translated code
func nth(ptr *node, n int) (r int) {
  return 
}

jcp19 avatar Jan 29 '21 14:01 jcp19

Besides, import "sync" is wrongly translated to import sync sync

jcp19 avatar Jan 29 '21 15:01 jcp19