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
bug in new code generator: recursive + inline + duplicate typeclass #1646
Comments
We had similar incorrect annotations in the |
Would it be possible to give an error at the |
I considered adding the check, but gave up for now since the current code generator accepts it. @[inlineIfReduce]
def List.toArrayAux : List α → Array α → Array α
| nil, r => r
| cons a as, r => toArrayAux as (r.push a) If we decide to implement the check at declaration time, we should probably do it inside the code generator where we have access to all information: mutual recursion, recursion in computationally relevant parts, etc. |
I think it would be good to give an error here if by some conservative check you can ensure that inlining will run away, which by my understanding would be any recursion at all (a loop in the call graph). You could also do a similar analysis for @[inlineIfReduce] partial def loop (xs : List A) : List A :=
match xs with
| [] => []
| x :: xs => loop (x :: xs) |
Yes, these are useful improvements, but I will not be implementing them in the near future. For now, we will have to survive with the "function inline stack" error message. I found it very effective. |
👍 |
The given code is buggy for two reasons: It has an
@[inline]
attribute even though it is recursive, and theforIn
function takes two instances of[Monad m]
(one from the variable line and one from the declaration). These interact in some way to cause the stack overflow in the inliner.The text was updated successfully, but these errors were encountered: