なかだです。

ifの式に対する警告が、対応するendの行になるのは分かりにくいと思
います。

$ ruby -wc
if while false
end

end	# ここになる
-:3: warning: void value expression
Syntax OK

それと、代入で同じ警告が二回出ます。node_assign()やassignable()
のrhsはほとんどがvalue_expr()済みのようですし、多重代入のほうも
mrhsの時点でvoidでないはずなのでは。

$ ruby -wc
a = while false; end
-:1: warning: void value expression
-:1: warning: void value expression
Syntax OK

$ ruby -wc
a, b = while false; end
-:1: warning: void value expression
-:1: warning: void value expression
Syntax OK


Index: parse.y =================================================================== RCS file: /cvs/ruby/src/ruby/parse.y,v retrieving revision 1.153 diff -u -2 -p -r1.153 parse.y --- parse.y 2002/02/14 08:47:58 1.153 +++ parse.y 2002/02/17 00:33:28 @@ -510,5 +510,4 @@ stmt : kALIAS fitem {lex_state = EXPR_F | mlhs '=' mrhs { - value_expr($3); $1->nd_value = $3; $$ = $1; @@ -1353,44 +1352,39 @@ primary : literal fixpos($$, $1); } - | kIF expr then + | kIF expr {value_expr($2);} then compstmt if_tail kEND { - value_expr($2); - $$ = NEW_IF(cond($2), $4, $5); + $$ = NEW_IF(cond($2), $5, $6); fixpos($$, $2); } - | kUNLESS expr then + | kUNLESS expr {value_expr($2);} then compstmt opt_else kEND { - value_expr($2); - $$ = NEW_UNLESS(cond($2), $4, $5); + $$ = NEW_UNLESS(cond($2), $5, $6); fixpos($$, $2); } - | kWHILE {COND_PUSH(1);} expr do {COND_POP();} + | kWHILE {COND_PUSH(1);} expr {COND_POP(); value_expr($3);} do compstmt kEND { - value_expr($3); $$ = NEW_WHILE(cond($3), $6, 1); fixpos($$, $3); } - | kUNTIL {COND_PUSH(1);} expr do {COND_POP();} + | kUNTIL {COND_PUSH(1);} expr {COND_POP(); value_expr($3);} do compstmt kEND { - value_expr($3); $$ = NEW_UNTIL(cond($3), $6, 1); fixpos($$, $3); } - | kCASE expr opt_terms + | kCASE expr {value_expr($2);} opt_terms case_body kEND { - value_expr($2); - $$ = NEW_CASE($2, $4); + $$ = NEW_CASE($2, $5); fixpos($$, $2); } @@ -1399,9 +1393,8 @@ primary : literal $$ = $3; } - | kFOR block_var kIN {COND_PUSH(1);} expr do {COND_POP();} + | kFOR block_var kIN {COND_PUSH(1);} expr {COND_POP(); value_expr($5);} do compstmt kEND { - value_expr($5); $$ = NEW_FOR($2, $5, $8); fixpos($$, $2); @@ -1492,7 +1485,6 @@ primary : literal cur_mid = $<id>3; } - | kDEF singleton dot_or_colon {lex_state = EXPR_FNAME;} fname + | kDEF singleton dot_or_colon {lex_state = EXPR_FNAME; value_expr($2);} fname { - value_expr($2); in_single++; local_push(); @@ -1543,10 +1535,9 @@ do : term if_tail : opt_else - | kELSIF expr then + | kELSIF expr {value_expr($2);} then compstmt if_tail { - value_expr($2); - $$ = NEW_IF(cond($2), $4, $5); + $$ = NEW_IF(cond($2), $5, $6); fixpos($$, $2); } @@ -1905,4 +1896,5 @@ f_opt : tIDENTIFIER '=' arg else if (local_id($1)) yyerror("duplicate optional argument name"); + value_expr($3); $$ = assignable($1, $3); } @@ -4310,9 +4302,4 @@ gettable(id) if (local_id(id)) return NEW_LVAR(id); /* method call without arguments */ -#if 0 - /* Rite will warn this */ - rb_warn("ambiguous identifier; %s() or self.%s is better for method call", - rb_id2name(id), rb_id2name(id)); -#endif return NEW_VCALL(id); } @@ -4338,5 +4325,4 @@ assignable(id, val) NODE *val; { - value_expr(val); if (id == kSELF) { yyerror("Can't change the value of self"); @@ -4464,5 +4450,4 @@ node_assign(lhs, rhs) if (!lhs) return 0; - value_expr(rhs); switch (nd_type(lhs)) { case NODE_GASGN: @@ -4498,4 +4483,13 @@ value_expr(node) switch (nd_type(node)) { + case NODE_VCALL: + /* Rite will warn this always */ + { + char *name = rb_id2name(node->nd_mid); + rb_warning("ambiguous identifier; %s() or self.%s is better for method call", + name, name); + } + return Qfalse; + case NODE_WHILE: case NODE_UNTIL:
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦