Skip to content

Commit ab2cde2

Browse files
committed
Avoid runtime production crash
1 parent 3fd88ae commit ab2cde2

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

crates/biome_js_type_info/src/globals.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub static GLOBAL_RESOLVER: LazyLock<Arc<GlobalsResolver>> =
2929
LazyLock::new(|| Arc::new(GlobalsResolver::default()));
3030

3131
pub static GLOBAL_TYPE_MEMBERS: LazyLock<Vec<TypeMember>> = LazyLock::new(|| {
32-
// use crate::globals_ids::*;
3332
(0..NUM_PREDEFINED_TYPES)
3433
.map(TypeId::new)
3534
.map(|id| {

crates/biome_js_type_info/src/globals_builder.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ impl GlobalsResolverBuilder {
2222
/// Fill a previously reserved type slot with actual type data.
2323
pub fn set_type_data(&mut self, id: TypeId, data: TypeData) {
2424
let index = id.index();
25-
assert!(
25+
debug_assert!(
2626
index < self.types.len(),
2727
"TypeId {index} out of bounds (len: {})",
2828
self.types.len()
2929
);
30-
assert!(
30+
debug_assert!(
3131
self.types[index].is_none(),
3232
"Type at index {index} already set"
3333
);
@@ -39,13 +39,8 @@ impl GlobalsResolverBuilder {
3939
let types: Vec<Arc<TypeData>> = self
4040
.types
4141
.into_iter()
42-
.enumerate()
43-
.map(|(i, opt)| {
44-
Arc::new(opt.unwrap_or_else(|| {
45-
// Make sure we only reserve just enough for what we need
46-
panic!("Type at index {i} was reserved but never filled")
47-
}))
48-
})
42+
.map(|opt| Arc::new(
43+
opt.unwrap_or(TypeData::Unknown)))
4944
.collect();
5045

5146
GlobalsResolver {

0 commit comments

Comments
 (0)