Replace panic! with internal_error!

This commit is contained in:
Elias Mulhall 2024-05-22 15:42:13 -04:00
parent 479feca396
commit 3120a1ea46

View file

@ -1,4 +1,5 @@
use roc_types::subs::{Rank, Variable}; use roc_types::subs::{Rank, Variable};
use roc_error_macros::internal_error;
const DEFAULT_POOLS: usize = 8; const DEFAULT_POOLS: usize = 8;
@ -27,14 +28,14 @@ impl Pools {
pub fn get_mut(&mut self, rank: Rank) -> &mut Vec<Variable> { pub fn get_mut(&mut self, rank: Rank) -> &mut Vec<Variable> {
match self.0.get_mut(rank.into_usize()) { match self.0.get_mut(rank.into_usize()) {
Some(reference) => reference, Some(reference) => reference,
None => panic!("Compiler bug: could not find pool at rank {rank}"), None => internal_error!("Compiler bug: could not find pool at rank {rank}"),
} }
} }
pub fn get(&self, rank: Rank) -> &Vec<Variable> { pub fn get(&self, rank: Rank) -> &Vec<Variable> {
match self.0.get(rank.into_usize()) { match self.0.get(rank.into_usize()) {
Some(reference) => reference, Some(reference) => reference,
None => panic!("Compiler bug: could not find pool at rank {rank}"), None => internal_error!("Compiler bug: could not find pool at rank {rank}"),
} }
} }
@ -46,7 +47,7 @@ impl Pools {
let last = self let last = self
.0 .0
.pop() .pop()
.unwrap_or_else(|| panic!("Attempted to split_last() on non-empty Pools")); .unwrap_or_else(|| internal_error!("Attempted to split_last() on non-empty Pools"));
(last, self.0) (last, self.0)
} }