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

Removed double panics from drop #45

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;

use std::cell::RefCell;
use std::thread::panicking;

use crate::{alloc::ArenaAllocator, typing::template::TemplateInput};

Expand Down Expand Up @@ -178,7 +179,7 @@ impl<'linker> ErrorCollector<'linker> {

impl<'l> Drop for ErrorCollector<'l> {
fn drop(&mut self) {
if !self.error_store.borrow().is_untouched() {
if !self.error_store.borrow().is_untouched() && !panicking() {
panic!("ErrorCollector should have been emptied!");
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/typing/delayed_constraint.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::thread::panicking;



#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -58,6 +60,8 @@ impl<T> DelayedConstraintsList<T> {

impl<T> Drop for DelayedConstraintsList<T> {
fn drop(&mut self) {
assert_eq!(self.0.len(), 0, "DelayedConstraintsList was not resolved.");
if !panicking() {
assert_eq!(self.0.len(), 0, "DelayedConstraintsList was not resolved.");
}
}
}
5 changes: 4 additions & 1 deletion src/typing/type_inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::cell::{OnceCell, RefCell};
use std::fmt::Debug;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut, Index};
use std::thread::panicking;

use crate::block_vector::{BlockVec, BlockVecIter};
use crate::errors::ErrorInfo;
Expand Down Expand Up @@ -166,7 +167,9 @@ impl<MyType : HindleyMilner<VariableIDMarker>+Clone, VariableIDMarker : UUIDMark

impl<MyType: HindleyMilner<VariableIDMarker>, VariableIDMarker: UUIDMarker> Drop for TypeSubstitutor<MyType, VariableIDMarker> {
fn drop(&mut self) {
assert!(self.failed_unifications.borrow().is_empty(), "Errors were not extracted before dropping!");
if !panicking() {
assert!(self.failed_unifications.borrow().is_empty(), "Errors were not extracted before dropping!");
}
}
}

Expand Down
Loading