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 the returned value of self.get_context() before unwrap it. #38

Closed
wants to merge 2 commits into from

Conversation

zhaopinglu
Copy link

Same as for other.get_context()

Copy link
Owner

@rrevenantt rrevenantt left a comment

Choose a reason for hiding this comment

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

Thanks, can you show the grammar which triggers that panic?

@@ -30,6 +30,10 @@ impl Eq for ATNConfig {}

impl PartialEq for ATNConfig {
fn eq(&self, other: &Self) -> bool {
if self.get_context().is_none() || other.get_context().is_none() {
Copy link
Owner

Choose a reason for hiding this comment

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

This will return false if both of them are None which is wrong.

Since i was writing that code, <Arc as PartialEq>::eq has been optimized with pointer comparison inside std itself, so better solution would be to replace whole Arc::ptr_eq stuff with direct comparison of self.contexts

rrevenantt added a commit that referenced this pull request Jul 22, 2022
@rrevenantt rrevenantt mentioned this pull request Jul 22, 2022
36 tasks
@rrevenantt rrevenantt deleted the branch rrevenantt:v0.3 July 22, 2022 13:59
@rrevenantt rrevenantt closed this Jul 22, 2022
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.

2 participants