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

ruby-changes:57753

From: Jeremy <ko1@a...>
Date: Sun, 15 Sep 2019 07:32:48 +0900 (JST)
Subject: [ruby-changes:57753] 1edcfd6107 (master): Issue a warning if invalid kw_splat is passed to *_kw function

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

From 1edcfd610703fb6f773e8f31f88f8ca920bda1ac Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Sat, 14 Sep 2019 13:57:39 -0700
Subject: Issue a warning if invalid kw_splat is passed to *_kw function

This should only happen if the API is misused.  It's much better
to warn here and fix the problem, versus to try to debug TypeErrors
or segfaults later.

diff --git a/vm_eval.c b/vm_eval.c
index b5d6dcc..c896a44 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -255,6 +255,12 @@ add_empty_keyword(int *argc, const VALUE **argv, int *kw_splat) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L255
             *kw_splat = rb_keyword_given_p();
         }
     }
+
+    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;
+    }
+
     return 0;
 }
 
-- 
cgit v0.10.2


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

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