parapluu / encore

The Encore compiler.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Forward cannot be used in a method that also uses return

kikofernandez opened this issue · comments

It seems like forward cannot be used in a method that also uses return. This example compiles to C raising an error:

active class B
  var x: String = "hola"
  def test(): (int, int)
    (3, 4)
  end
end

active class Main
  def test(): (int, int)
    val b = new B
    if true then
      return (3, 4)
    else
      forward(b!test())
    end
  end

  def main(): unit
    ()
  end
end

Error message:

encorec test.enc
test_src/Main.encore.c:264:5: error: void function '_enc__method__test_Main_test_async' should not return a value
      [-Wreturn-type]
    return _tuple_6;
    ^      ~~~~~~~~
1 error generated.
 *** Compilation failed with exit code 1 ***

Duplicate of #816.
If something written here is new, add it to the previous issue.