effekt-lang / effekt

A language with lexical effect handlers and lightweight effect polymorphism
https://effekt-lang.org
MIT License
334 stars 24 forks source link

Region variable not found in LLVM backend #696

Closed phischu closed 3 days ago

phischu commented 6 days ago

Consider the following program:

effect retry(): Nothing

def mark[R] { program: () => R / retry }: R = {
  def here(): R =
    try {
      program()
    } with retry {
      here()
    }
  here()
}

def main(): Unit = {
  region outer {
    mark {
      var x in outer = 0
      x = x + 1
      println("x = " ++ x.show)
      do retry()
    }
  }
}

When I run it with the llvm backend it crashes with:

opt-15: ./out/repro.ll:1200:84: error: use of undefined value '%outer_2242'
        %pair_25 = call ccc {%Resumption, %Stack} @shift(%Stack %stack_15, %Prompt %outer_2242)