From 436191abe05a12be17bb6c184790ee39d6fabffb Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 8 Feb 2024 09:43:07 -0500 Subject: [PATCH] Replace assert with RUBY_ASSERT in enum.c 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. --- enum.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/enum.c b/enum.c index 7f15836ba87e77..54ccf61c7855e1 100644 --- a/enum.c +++ b/enum.c @@ -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; @@ -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); } @@ -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); }