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

Check bounds when looking up type parameters #13480

Merged
merged 1 commit into from
Apr 14, 2014
Merged

Conversation

edwardw
Copy link
Contributor

@edwardw edwardw commented Apr 12, 2014

A mismatched type with more type parameters than the expected one causes
typeck looking up out of the bound of type parameter vector, which
leads to ICE.

Closes #13466

@@ -394,7 +394,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
let ident = match cx.ty_param_defs.borrow().find(&did.node) {
Some(def) => token::get_ident(def.ident).get().to_str(),
// This should not happen...
Copy link
Member

Choose a reason for hiding this comment

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

So this is allowed to happen now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is just needed in the error message. BUG[0] is way too ugly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

E.g., otherwise the first error in the test would be "ERROR mismatched types: expected uint but found BUG[0]."

Copy link
Member

Choose a reason for hiding this comment

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

I mean, the comment "this should not happen" implies that this code path should never be hit, but this patch is now using it for legitimate error-reporting purposes.

The fact that the comment exists implies that it's expected that this sort of error is handled/reported elsewhere. Of course, it may be that this expectation is now incorrect, and that this is the correct codepath for the error. (In which case, the comment should be removed.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I think this can happen. The comment has been changed accordingly.

A mismatched type with more type parameters than the expected one causes
`typeck` looking up out of the bound of type parameter vector, which
leads to ICE.

Closes rust-lang#13466
bors added a commit that referenced this pull request Apr 14, 2014
A mismatched type with more type parameters than the expected one causes
`typeck` looking up out of the bound of type parameter vector, which
leads to ICE.

Closes #13466
@bors bors closed this Apr 14, 2014
@bors bors merged commit fc043c0 into rust-lang:master Apr 14, 2014
@edwardw edwardw deleted the vtable-ice branch April 14, 2014 19:17
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.

error: mismatched type -> internal compiler error: unexpected failure
4 participants