Skip to content

Incorrect translation of polymorphic type #809

@PhucVH888

Description

@PhucVH888

The polymorphic type is translated incorrectly according to the following example test.enc.

active class Base[t]
  var v  : t

  def init(v : t) : unit
    this.v = v
  end

  def base() : t
    this.v
  end
end

active class Foo
  def foo[sharable ty](arg : Fut[ty]) : ty
    get(arg ~~> fun(x : ty) : ty => get((new Base[ty](x)) ! base()))
  end
end

active class Main
  def main() : unit
    val arg = (new Base[int](42)) ! base()
    println("{}", get((new Foo) ! foo[int](arg)))
  end
end

Here is the error message.

$ encorec --run test.enc
test_src/Foo.encore.c:208:38: error: use of undeclared identifier '_enc__type_ty'
  _enc__type_init__test_Base(_new_0, _enc__type_ty);
                                     ^
1 error generated.
 *** Compilation failed with exit code 1 ***

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