From 668b12e7566282f6c0165252e2b2f5432964020a Mon Sep 17 00:00:00 2001 From: dearblue Date: Wed, 24 Nov 2021 23:34:31 +0900 Subject: Check more `MRB_ARGS_NONE()` The `__id__` method implemented in the C function has `MRB_ARGS_NONE()` specified, but it is also effective in the following cases. ```ruby p nil.__id__ opts: 1 rescue p :a p nil.method(:__id__).call 1 rescue p :b p nil.method(:__id__).call opts: 1 rescue p :c p nil.method(:__id__).to_proc.call 1 rescue p :d p nil.method(:__id__).to_proc.call opts: 1 rescue p :e p nil.method(:__id__).unbind.bind_call nil, 1 rescue p :f p nil.method(:__id__).unbind.bind_call nil, opts: 1 rescue p :g p nil.__send__ :__id__, 1 rescue p :h p nil.__send__ :__id__, opts: 1 rescue p :i ``` After applying this patch, all items will output symbols in the same way as CRuby. For this purpose, add `MRB_PROC_NOARG` to `struct RProc::flags`. --- include/mruby/proc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/mruby/proc.h b/include/mruby/proc.h index 31f40d379..1ba485783 100644 --- a/include/mruby/proc.h +++ b/include/mruby/proc.h @@ -83,6 +83,8 @@ struct RProc { } while (0) #define MRB_PROC_SCOPE 2048 #define MRB_PROC_SCOPE_P(p) (((p)->flags & MRB_PROC_SCOPE) != 0) +#define MRB_PROC_NOARG 4096 /* for MRB_PROC_CFUNC_FL, it would be something like MRB_ARGS_NONE() or MRB_METHOD_NOARG_FL */ +#define MRB_PROC_NOARG_P(p) (((p)->flags & MRB_PROC_NOARG) != 0) #define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v))) -- cgit v1.2.3