Skip to content

NamelessToNamed reconstructing contexts out of order #219

@jthywiss

Description

@jthywiss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions