Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NamelessToNamed reconstructing contexts out of order #219

Open
jthywiss opened this issue Jun 6, 2018 · 1 comment
Open

NamelessToNamed reconstructing contexts out of order #219

jthywiss opened this issue Jun 6, 2018 · 1 comment

Comments

@jthywiss
Copy link
Member

jthywiss commented Jun 6, 2018

Tranking, an Orc user, reported the following bug in orc.ast.oil.nameless.NamelessToNamed:

Date: Thu, 24 May 2018 14:55:14 +0800
From: Tranking

. . . . when I debug orc source code, I found that the nameless code which was compiled by NamedToNameless had an error when it rollback to named code which was compiled by NamelessToNamed, the error was caused by the method below:

def namelessToNamed(x: BoundVar, defn: Def, context: List[BoundVar], typecontext: List[BoundTypevar]): named.Def = {
  defn -> {
    case Def(typearity, arity, body, argtypes, returntype) => {
      val formals = (for (_ <- 0 until arity) yield new BoundVar()).toList
      val typeformals = (for (_ <- 0 until typearity) yield new BoundTypevar()).toList
      val newContext = formals ::: context
      val newTypeContext = typeformals ::: typecontext
      val newbody = namelessToNamed(body, newContext, newTypeContext)
      val newArgTypes = argtypes map { _ map { namelessToNamed(_, newTypeContext) } }
      val newReturnType = returntype map { namelessToNamed(_, newTypeContext) }
      named.Def(x, formals, newbody, typeformals, newArgTypes, newReturnType)
    }
  }
}

and the method is belong to the class of orc/ast/oil/nameless/NamelessToNamed. The error line is [val newContext ... ]. The correct code should be:

  val newContext = formals.reverse:::context
@jthywiss
Copy link
Member Author

jthywiss commented Jun 6, 2018

Tranking, thank you for the bug report!

It looks like the file was changed by the ODO merge since the time of Tranking's version, but the code is still there, currently at line 147. Need to check if typeformals are also affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant