Skip to content

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

@jackh726

Description

@jackh726

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions