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

ruby-changes:56005

From: Yusuke <ko1@a...>
Date: Tue, 4 Jun 2019 23:17:42 +0900 (JST)
Subject: [ruby-changes:56005] Yusuke Endoh: 0b0c6cb7e4 (trunk): compile.c: Remove the magical `(const NODE*) -1`

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

From 0b0c6cb7e4fa17247cb214c4eaf924617a55e9a7 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 4 Jun 2019 23:15:14 +0900
Subject: compile.c: Remove the magical `(const NODE*) -1`

It is used to represent "no default expression" for keyword argument:
`def foo(key:)`.  This change uses NODE_SPECIAL_REQUIRED_KEYWORD.

diff --git a/compile.c b/compile.c
index e1a8885..889dc32 100644
--- a/compile.c
+++ b/compile.c
@@ -1556,7 +1556,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, https://github.com/ruby/ruby/blob/trunk/compile.c#L1556
 	const NODE *val_node = node->nd_body->nd_value;
 	VALUE dv;
 
-	if (val_node == (const NODE *)-1) {
+	if (val_node == NODE_SPECIAL_REQUIRED_KEYWORD) {
 	    ++rkw;
 	}
 	else {
@@ -8012,7 +8012,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L8012
 	    LABEL *end_label = NEW_LABEL(nd_line(node));
 	    const NODE *default_value = node->nd_body->nd_value;
 
-	    if (default_value == (const NODE *)-1) {
+	    if (default_value == NODE_SPECIAL_REQUIRED_KEYWORD) {
 		/* required argument. do nothing */
 		COMPILE_ERROR(ERROR_ARGS "unreachable");
 		goto ng;
-- 
cgit v0.10.2


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

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