mirror of
https://github.com/enso-org/enso.git
synced 2024-09-11 21:27:15 +03:00
Fix bugs in TCO and test library (#1205)
This commit is contained in:
parent
72bf87c648
commit
73c748c4e9
@ -104,7 +104,10 @@ Text.it ~behavior pending=False =
|
||||
State.put Spec new_spec
|
||||
|
||||
run_spec ~behavior =
|
||||
maybeExc = case Panic.recover behavior of
|
||||
recovery = Panic.recover <|
|
||||
behavior
|
||||
Unit
|
||||
maybeExc = case recovery of
|
||||
_ -> Success
|
||||
result = maybeExc.catch ex->
|
||||
case ex of
|
||||
|
@ -154,7 +154,7 @@ case object TailCall extends IRPass {
|
||||
case binding @ IR.Expression.Binding(_, expression, _, _, _) =>
|
||||
binding
|
||||
.copy(
|
||||
expression = analyseExpression(expression, isInTailPosition)
|
||||
expression = analyseExpression(expression, isInTailPosition = false)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
case err: IR.Diagnostic =>
|
||||
|
@ -127,6 +127,20 @@ class TailCallTest extends CompilerTest {
|
||||
|
||||
ir.getMetadata(TailCall) shouldEqual Some(TailPosition.NotTail)
|
||||
}
|
||||
|
||||
"mark the value of a tail assignment as non-tail" in {
|
||||
implicit val ctx: InlineContext = mkTailContext
|
||||
val binding =
|
||||
"""
|
||||
|foo = a b
|
||||
|""".stripMargin.preprocessExpression.get.analyse
|
||||
.asInstanceOf[IR.Expression.Binding]
|
||||
binding.getMetadata(TailCall) shouldEqual Some(TailPosition.Tail)
|
||||
binding.expression.getMetadata(TailCall) shouldEqual Some(
|
||||
TailPosition.NotTail
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
"Tail call analysis on functions" should {
|
||||
|
Loading…
Reference in New Issue
Block a user