Skip to content
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

Fix infinite recursion in type checker on recursive items #17264

Merged
merged 2 commits into from
Sep 17, 2014

Conversation

bkoropoff
Copy link
Contributor

Recursive items are currently detected in the check_const pass which runs after type checking. This means a recursive static item used as an array length will cause type checking to blow the stack. This PR separates the recursion check out into a separate pass which is run before type checking.

Closes issue #17252

r? @nick29581

// option. This file may not be copied, modified, or distributed
// except according to those terms.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here explaining briefly what this file does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix

@nrc
Copy link
Member

nrc commented Sep 15, 2014

LGTM, just a few nits to clear up.

@bkoropoff
Copy link
Contributor Author

Force pushed new version with fixes

This new pass is run before type checking so that recursive items
are detected beforehand.  This prevents going into an infinite
recursion during type checking when a recursive item is used in
an array type.

As a bonus, use `span_err` instead of `span_fatal` so multiple
errors can be reported.

Closes issue rust-lang#17252
@bkoropoff
Copy link
Contributor Author

After some more discussion on IRC, I tweaked the pass to use span_err instead of span_fatal so multiple errors can be reported in a crate. This allowed the two test cases to be merged together. This version should be ready to go.

bors added a commit that referenced this pull request Sep 17, 2014
Recursive items are currently detected in the `check_const` pass which runs after type checking.  This means a recursive static item used as an array length will cause type checking to blow the stack.  This PR separates the recursion check out into a separate pass which is run before type checking.

Closes issue #17252

r? @nick29581
@bors bors closed this Sep 17, 2014
@bors bors merged commit 0818955 into rust-lang:master Sep 17, 2014
@bkoropoff bkoropoff deleted the issue-17252 branch September 20, 2014 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants