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

Tailrec improvements #5399

Merged
merged 5 commits into from Nov 9, 2018

Conversation

Projects
None yet
2 participants
@allanrenucci
Copy link
Member

allanrenucci commented Nov 6, 2018

No description provided.

Show resolved Hide resolved compiler/src/dotty/tools/dotc/transform/TailRec.scala Outdated
Show resolved Hide resolved compiler/src/dotty/tools/dotc/transform/TailRec.scala Outdated
Show resolved Hide resolved compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala Outdated
Show resolved Hide resolved compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala Outdated
Show resolved Hide resolved tests/pos/tailcall/i5163.scala Outdated
Show resolved Hide resolved tests/pos/tailcall/i5163.scala Outdated

@allanrenucci allanrenucci force-pushed the dotty-staging:fix-5163-bis branch from ff730ca to 089eb40 Nov 7, 2018

@sjrd

This comment has been minimized.

Copy link
Member

sjrd commented Nov 7, 2018

The optimization is incorrect. It is possible to re-enter a tail-pos context even from some places where we are in a non-tail-pos context. The most important example is when finding a return[label] expr where the label: { ... } block was in tail position, but the return was not. In that case, expr must be considered to be in tail position. This is critical for tail-recursive calls in the cases of a pattern match.

@allanrenucci allanrenucci force-pushed the dotty-staging:fix-5163-bis branch 5 times, most recently from 3eca547 to f8f2b4e Nov 8, 2018

@allanrenucci allanrenucci changed the title Fix #5163: Report tailrec failures on recursive call targeting supertype Tailrec improvements Nov 8, 2018

@allanrenucci allanrenucci force-pushed the dotty-staging:fix-5163-bis branch from f8f2b4e to e823e8b Nov 8, 2018

@allanrenucci allanrenucci force-pushed the dotty-staging:fix-5163-bis branch from e823e8b to ac42ec0 Nov 9, 2018

@allanrenucci allanrenucci requested a review from sjrd Nov 9, 2018

@sjrd

sjrd approved these changes Nov 9, 2018

allanrenucci added some commits Nov 7, 2018

Optimise the Tailrec phase
We can stop traversing a tree in Tailrec as soon as we are not in tail
position anymore and we are not within a labeled block in tail position.
We keep traversing the tree however if the method is @tailrec annotated
to report errors on eventual recursive calls.

@allanrenucci allanrenucci force-pushed the dotty-staging:fix-5163-bis branch from ac42ec0 to a129cbd Nov 9, 2018

@allanrenucci allanrenucci merged commit a9029dc into lampepfl:master Nov 9, 2018

2 checks passed

CLA User signed CLA
Details
continuous-integration/drone/pr the build was successful
Details

@allanrenucci allanrenucci deleted the dotty-staging:fix-5163-bis branch Nov 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment