Skip to content

Non-ambigous answer that can replace an ambiguous answer may panic #302

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

Closed
jackh726 opened this issue Dec 2, 2019 · 4 comments
Closed
Labels
bug A bug

Comments

@jackh726
Copy link
Member

jackh726 commented Dec 2, 2019

It's possible that a new answer may not be ambiguous, but an older answer was. In this case push_answer on Table does not insert a new answer, but still returns true.

let added = match self.answers_hash.entry(answer.subst.clone()) {

However, if true is returned, then it's propagated up and eventually the AnswerIndex is incremented

self.answer.increment();

Then, in the next iteration of checking for an answer, the AnswerIndex is not the next index, so this assertion can fail:

assert_eq!(self.tables[table].next_answer_index(), answer);

Simply changing push_answer to panic whenever a new answer would replace an old one doesn't cause any tests to fail. So if this is a valid case, then a test should be added.

Relevant zulip: https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/design.20meeting.202019.2E12.2E02/near/182380076

@lnicola
Copy link
Member

lnicola commented Dec 29, 2019

This causes a panic when running rust-analyzer over itself, as seen in rust-lang/rust-analyzer#2675.

@jackh726
Copy link
Member Author

@lnicola Thanks for the report. It would be nice to get min repro for this, but I'll start looking at a fix.

@jackh726
Copy link
Member Author

jackh726 commented Jan 5, 2020

This can also be reproduced with the existing test gat_unify_with_implied_wc with a max_size of 3.

@jackh726
Copy link
Member Author

This was fixed in #433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug
Projects
None yet
Development

No branches or pull requests

2 participants