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

ruby-changes:51251

From: nobu <ko1@a...>
Date: Fri, 18 May 2018 09:36:33 +0900 (JST)
Subject: [ruby-changes:51251] nobu:r63457 (trunk): parse.y: relax literal in condition warnings

nobu	2018-05-18 09:36:24 +0900 (Fri, 18 May 2018)

  New Revision: 63457

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63457

  Log:
    parse.y: relax literal in condition warnings
    
    * parse.y (cond0): do not warn literal boolean (true and false) in
      condition expressions, as they are often used as infinite loops,
      deactivated code block, etc.

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 63456)
+++ parse.y	(revision 63457)
@@ -9823,6 +9823,10 @@ cond0(struct parser_params *p, NODE *nod https://github.com/ruby/ruby/blob/trunk/parse.y#L9823
 		warn_unless_e_option(p, node, "regex literal in condition");
 	    nd_set_type(node, NODE_MATCH);
 	}
+	else if (node->nd_lit == Qtrue ||
+		 node->nd_lit == Qfalse) {
+	    /* booleans are OK, e.g., while true */
+	}
 	else {
 	    if (!method_op)
 		parser_warning(p, node, "literal in condition");

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

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