summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorKoichi Sasada <[email protected]>2024-03-27 07:29:38 +0900
committerKoichi Sasada <[email protected]>2024-04-15 12:08:07 +0900
commit9180e33ca3a5886fec3f9e0a2f48072b55914e65 ()
tree6ce301e829b11f7189befef36a80924287d5d386 /iseq.c
parent515e52a0b1ce61ccaffe9183bcb78dda95a64907 (diff)
show warning for unused block
With verbopse mode (-w), the interpreter shows a warning if a block is passed to a method which does not use the given block. Warning on: * the invoked method is written in C * the invoked method is not `initialize` * not invoked with `super` * the first time on the call-site with the invoked method (`obj.foo{}` will be warned once if `foo` is same method) [Feature #15554] `Primitive.attr! :use_block` is introduced to declare that primitive functions (written in C) will use passed block. For minitest, test needs some tweak, so use https://.com/minitest/minitest/commit/ea9caafc0754b1d6236a490d59e624b53209734a for `test-bundled-gems`.
-rw-r--r--iseq.c6
1 files changed, 6 insertions, 0 deletions
@@ -538,6 +538,11 @@ iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, int
RB_OBJ_WRITE(iseq, &loc->label, name);
RB_OBJ_WRITE(iseq, &loc->base_label, name);
loc->first_lineno = first_lineno;
if (code_location) {
loc->node_id = node_id;
loc->code_location = *code_location;
@@ -1011,6 +1016,7 @@ pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpa
{
rb_iseq_t *iseq = iseq_alloc();
ISEQ_BODY(iseq)->prism = true;
if (!option) option = &COMPILE_OPTION_DEFAULT;