Skip to content

Commit 249a1fb

Browse files
committed
Show more in RBIMPL_ASSERT_TYPE
1 parent b834c62 commit 249a1fb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

include/ruby/assert.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,18 @@ RBIMPL_WARNING_IGNORED(-Wgnu-zero-variadic-macro-arguments)
299299
*/
300300
#if RUBY_DEBUG
301301
# define RBIMPL_ASSERT_OR_ASSUME RUBY_ASSERT_ALWAYS
302+
#elif ! defined(RBIMPL_VA_OPT_ARGS)
303+
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSUME(expr)
302304
#elif RBIMPL_COMPILER_BEFORE(Clang, 7, 0, 0)
303305
# /* See commit 67d259c5dccd31fe49d417fec169977712ffdf10 */
304-
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
306+
# define RBIMPL_ASSERT_OR_ASSUME(...) RBIMPL_ASSERT_NOTHING
305307
#elif defined(RUBY_ASSERT_NOASSUME)
306308
# /* See commit d300a734414ef6de7e8eb563b7cc4389c455ed08 */
307-
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
309+
# define RBIMPL_ASSERT_OR_ASSUME(...) RBIMPL_ASSERT_NOTHING
308310
#elif ! defined(RBIMPL_HAVE___ASSUME)
309-
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
311+
# define RBIMPL_ASSERT_OR_ASSUME(...) RBIMPL_ASSERT_NOTHING
310312
#else
311-
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSUME(expr)
313+
# define RBIMPL_ASSERT_OR_ASSUME(expr, ...) RBIMPL_ASSUME(expr)
312314
#endif
313315

314316
#endif /* RUBY_ASSERT_H */

include/ruby/internal/value_type.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@
9696
#define RB_TYPE_P RB_TYPE_P
9797
#define Check_Type Check_Type
9898

99-
#define RBIMPL_ASSERT_TYPE(v, t) RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P((v), (t)))
99+
#ifdef RBIMPL_VA_OPT_ARGS
100+
# define RBIMPL_ASSERT_TYPE(v, t) \
101+
RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P(v, t), "actual type: %d", rb_type(v))
102+
#else
103+
# define RBIMPL_ASSERT_TYPE(v, t) RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P(v, t))
104+
#endif
100105
/** @endcond */
101106

102107
/** @old{rb_type} */

0 commit comments

Comments
 (0)