Hi,
At Wed, 14 Apr 2004 18:39:23 +0900,
Robert Klemme wrote in [ruby-talk:97118]:
Sorry if this is similar to other cases already discussed. I was paying
attention, but those cases seemed more ambiguous, hence the warning.
I can only guess: maybe it's because the line "puts([1,2,3].include? 1,2)"
would be amiguous?
You're correct, and Gavin may be also.
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.319
diff -U2 -p -d -r1.319 parse.y
--- parse.y 5 Apr 2004 13:16:40 -0000 1.319
+++ parse.y 14 Apr 2004 11:17:50 -0000
@@ -119,4 +119,5 @@ static void void_expr0();
static void void_stmts();
static NODE *remove_begin();
+static void warn_to_parenthesize();
#define value_expr(node) value_expr0((node) = remove_begin(node))
#define void_expr(node) void_expr0((node) = remove_begin(node))
@@ -1217,5 +1218,5 @@ aref_args : none
| command opt_nl
{
- rb_warn("parenthesize argument(s) for future version");
+ warn_to_parenthesize($1);
$$ = NEW_LIST($1);
}
@@ -1250,5 +1251,5 @@ paren_args : '(' none ')'
| '(' block_call rparen
{
- rb_warn("parenthesize argument for future version");
+ warn_to_parenthesize($2);
$$ = NEW_LIST($2);
}
@@ -1266,5 +1267,5 @@ opt_paren_args : none
call_args : command
{
- rb_warn("parenthesize argument(s) for future version");
+ warn_to_parenthesize($1);
$$ = NEW_LIST($1);
}
@@ -4512,4 +4513,17 @@ fixpos(node, orig)
node->nd_file = orig->nd_file;
nd_set_line(node, nd_line(orig));
+}
+
+static void
+warn_to_parenthesize(node)
+ NODE *node;
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ case NODE_FCALL:
+ if (!node->nd_args) return;
+ if (node->nd_args->nd_alen == 1) return;
+ }
+ rb_warn("parenthesize argument(s) for future version");
}