mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
Multireturn bugfix (#238)
This commit is contained in:
parent
3eb3ecc221
commit
f7aa118006
@ -1,15 +1,20 @@
|
||||
service Getter("test"):
|
||||
createStr: u32 -> string
|
||||
service GetStr("multiret-test"):
|
||||
retStr: string -> string
|
||||
|
||||
service OpO("op"):
|
||||
identity: string -> string
|
||||
service GetNum("multiret-num"):
|
||||
retNum: -> u8
|
||||
|
||||
-- a question mark means that this constant could be rewritten before this definition
|
||||
const anotherConst ?= "default-str"
|
||||
const uniqueConst ?= 5
|
||||
const someNum = 5
|
||||
const someStr = "some-str"
|
||||
|
||||
func callConstant() -> []string, u8:
|
||||
func tupleFunc() -> string, u8:
|
||||
str <- GetStr.retStr(someStr)
|
||||
n <- GetNum.retNum()
|
||||
<- str, n
|
||||
|
||||
func multiReturnFunc(somethingToReturn: []u8, smthOption: ?string) -> []string, u8, string, []u8, ?string, u8:
|
||||
res: *string
|
||||
res <- Getter.createStr(uniqueConst)
|
||||
res <- OpO.identity(anotherConst)
|
||||
<- res, 5
|
||||
res <- GetStr.retStr(someStr)
|
||||
res <- GetStr.retStr("random-str")
|
||||
res, tNum <- tupleFunc()
|
||||
<- res, 5, someStr, somethingToReturn, smthOption, tNum
|
||||
|
@ -167,7 +167,7 @@ case class FuncCallable(
|
||||
case ((ops, rets), (_, r)) => (ops, r :: rets)
|
||||
}
|
||||
|
||||
FuncOps.seq(ops.reverse: _*) -> rets
|
||||
FuncOps.seq(ops.reverse: _*) -> rets.reverse
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,13 @@ case class ResolveFunc(
|
||||
case t => t
|
||||
}).toLabelledList(returnVar)
|
||||
|
||||
val retModel = returnType.map { case (l, t) => VarModel(l, t) }
|
||||
|
||||
val funcCall = Call(
|
||||
func.arrowType.domain.toLabelledList().map(ad => VarModel(ad._1, ad._2)),
|
||||
returnType.map { case (l, t) => Call.Export(l, t) }
|
||||
)
|
||||
|
||||
FuncCallable(
|
||||
wrapCallableName,
|
||||
transform(
|
||||
@ -51,13 +58,10 @@ case class ResolveFunc(
|
||||
FuncOps
|
||||
.callArrow(
|
||||
func.funcName,
|
||||
Call(
|
||||
func.arrowType.domain.toLabelledList().map(ad => VarModel(ad._1, ad._2)),
|
||||
returnType.map { case (l, t) => Call.Export(l, t) }
|
||||
)
|
||||
) :: returnType.headOption
|
||||
.map(_ => returnCallback(returnType.map { case (l, t) => VarModel(l, t) }))
|
||||
.toList: _*
|
||||
funcCall
|
||||
) :: (returnType.headOption
|
||||
.map(_ => returnCallback(retModel))
|
||||
.toList): _*
|
||||
)
|
||||
),
|
||||
ArrowType(ConsType.cons(func.funcName, func.arrowType, NilType), NilType),
|
||||
|
@ -96,6 +96,7 @@ class FuncSem[F[_]](val expr: FuncExpr[F]) extends AnyVal {
|
||||
.map(vs.prependedAll)
|
||||
)
|
||||
})
|
||||
.map(_.reverse)
|
||||
.flatMap(retModel =>
|
||||
// Erase arguments and internal variables
|
||||
A.endScope() >> N.endScope() >> (bodyGen match {
|
||||
|
@ -94,7 +94,7 @@ object ConsType {
|
||||
}
|
||||
|
||||
case class LabelledConsType(label: String, `type`: Type, tail: ProductType) extends ConsType {
|
||||
override def toString: String = s"($label: " + `type` + s" :: $tail"
|
||||
override def toString: String = s"($label: " + `type` + s") :: $tail"
|
||||
}
|
||||
|
||||
case class UnlabelledConsType(`type`: Type, tail: ProductType) extends ConsType {
|
||||
|
Loading…
Reference in New Issue
Block a user