Skip to content

Restrictive forward's type #792

@PhucVH888

Description

@PhucVH888

The forward's type is too restrictive. When using nested forward in the following example, an extra variable arg1 is necessary for passing the typecheck. A better way is to relax the forward's type so that no extra variable is used to do the trick.

active class Base
  def base() : int
    42
  end
end

active class Bar
  def bar() : int
    24
  end
end

active class Foo
  def foo(b : bool) : int
    val arg1 = (new Bar) ! bar()
    val arg2 = (new Base) ! base()
    forward(if b then
              forward(arg1)
              arg1 -- required to make typecheck
            else
              arg2
            end)
  end
end

active class Main
  def main() : unit
    println("{}", get((new Foo) ! foo(true)))
    println("{}", get((new Foo) ! foo(false)))
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions