[前][次][番号順一覧][スレッド一覧]

ruby-changes:58054

From: Jeremy <ko1@a...>
Date: Mon, 30 Sep 2019 23:07:03 +0900 (JST)
Subject: [ruby-changes:58054] a8c436d9a1 (master): Issue keyword flag warning even with no arguments

https://git.ruby-lang.org/ruby.git/commit/?id=a8c436d9a1

From a8c436d9a1d333e9391c78d4ffd32568a56534a6 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Sun, 29 Sep 2019 22:49:43 -0700
Subject: Issue keyword flag warning even with no arguments

If the keyword flag is set, there should be at least one argument,
if there isn't, that is a sign the keyword flag was passed when it
should not have been.

diff --git a/vm_eval.c b/vm_eval.c
index c741773..1c205f0 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -256,7 +256,7 @@ rb_adjust_argv_kw_splat(int *argc, const VALUE **argv, int *kw_splat) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L256
         }
     }
 
-    if (*kw_splat && *argc > 0 && !RB_TYPE_P((*argv)[(*argc)-1], T_HASH)) {
+    if (*kw_splat && (*argc == 0 || !RB_TYPE_P((*argv)[(*argc)-1], T_HASH))) {
         rb_warn("Keyword flag passed calling internal method, but last entry is not a hash, unsetting keyword flag");
         *kw_splat = 0;
     }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]