Skip to content

Commit

Permalink
refactor(data_structures): add debug assertion to SparseStack (#6218)
Browse files Browse the repository at this point in the history
Just add an additional debug assert.
  • Loading branch information
overlookmotel committed Oct 1, 2024
1 parent adc5381 commit 61805fd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions crates/oxc_data_structures/src/stack/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl<T> SparseStack<T> {
self.values.push(init());
}

debug_assert!(!self.values.is_empty());
// SAFETY: Last `self.has_values` is only `true` if there's a corresponding value in `self.values`.
// This invariant is maintained in `push`, `pop`, `take_last`, and `last_or_init`.
// Here either last `self.has_values` was already `true`, or it's just been set to `true`
Expand Down

0 comments on commit 61805fd

Please sign in to comment.