You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consider following signature: def toListOfString(tuple: Tuple): List[String]
to be invoked with toListOfString(1,2,3)
deftoListOfString(tuple: Tuple):List[String] =
tuple matchcaseEmptyTuple=>List()
case head *: tail =>List(head.toString) ++ toListOfString(tail)
// works => List(1, 2, 3)
// inline definlinedeftoListOfString(tuple: Tuple):List[String] =
tuple matchcaseEmptyTuple=>List()
case head *: tail =>List(head.toString) ++ toListOfString(tail)
// Maximal number of successive inlines (32) exceeded,// Maybe this is caused by a recursive inline method?// I understand this, the compiler is trying to endlessly nest the same piece of code and fails
// inline matchinlinedeftoListOfString(tuple: Tuple):List[String] =inline tuple matchcaseEmptyTuple=>List()
case head *: tail =>List(head.toString) ++ toListOfString(tail)
// cannot reduce inline match with// scrutinee: tuple$proxy1 : (tuple$proxy1 : (Int, Int, Int))// patterns : case EmptyTuple// case *:.unapply[Any, Tuple](head @ _, tail @ _):Any *: Tuple// inline tuple match
Expectation
This as a request for clarification (tag it as a question), promote it as a bug in case something needs to be fixed.
Is my expectation justified, that the variant with inline match should compile, like the non-inline toListOfString does?
The text was updated successfully, but these errors were encountered:
perhaps in this case when the inline recursive call is evaluated there can be some sort of hashing to detect if the arguments changed, if no I would assume it would cause an infinite loop
^ however the above can't catch everything - if the arguments do change, perhaps they change in a way that actually grows the problem away from a base case - e.g. prepending to a tuple rather than removing its head
Could this be a similar problem to the match types? Maybe allow it when the types work out @bishabosha?
Of course, as you alluded to, this leaves behind a large class of problems where only the value changes.
This general problem (determine the termination of let's say def f(n) = if n != 1 then f(if n % 2 == 1 then 3*n+1 else n/2)) can only be circumvented.
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.0.0
Minimized code
consider following signature:
def toListOfString(tuple: Tuple): List[String]
to be invoked with
toListOfString(1,2,3)
Expectation
This as a request for clarification (tag it as a question), promote it as a bug in case something needs to be fixed.
Is my expectation justified, that the variant with
inline match
should compile, like the non-inline
toListOfString does?The text was updated successfully, but these errors were encountered: