Skip to content

Commit

Permalink
Replace assert with RUBY_ASSERT in enum.c
Browse files Browse the repository at this point in the history
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
  • Loading branch information
peterzhu2118 committed Feb 12, 2024
1 parent 11ffee8 commit 436191a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions enum.c
Expand Up @@ -4538,7 +4538,7 @@ struct enum_sum_memo {
static void
sum_iter_normalize_memo(struct enum_sum_memo *memo)
{
assert(FIXABLE(memo->n));
RUBY_ASSERT(FIXABLE(memo->n));
memo->v = rb_fix_plus(LONG2FIX(memo->n), memo->v);
memo->n = 0;

Expand Down Expand Up @@ -4640,7 +4640,7 @@ sum_iter_Kahan_Babuska(VALUE i, struct enum_sum_memo *memo)
static void
sum_iter(VALUE i, struct enum_sum_memo *memo)
{
assert(memo != NULL);
RUBY_ASSERT(memo != NULL);
if (memo->block_given) {
i = rb_yield(i);
}
Expand Down Expand Up @@ -4691,8 +4691,8 @@ hash_sum_i(VALUE key, VALUE value, VALUE arg)
static void
hash_sum(VALUE hash, struct enum_sum_memo *memo)
{
assert(RB_TYPE_P(hash, T_HASH));
assert(memo != NULL);
RUBY_ASSERT(RB_TYPE_P(hash, T_HASH));
RUBY_ASSERT(memo != NULL);

rb_hash_foreach(hash, hash_sum_i, (VALUE)memo);
}
Expand Down

0 comments on commit 436191a

Please sign in to comment.