Hi,

At Thu, 17 Apr 2003 07:55:46 +0900,
Dave Thomas wrote:
> I assumed that was referring to stuff with an implicit $_ or $., such as
> 
>    print if 10..20
> 
> or
> 
>    print if /cat/../dog/
> 
> I'm not sure I see the reason for deprecating the more general form.

Exactly.  And some new nodes are not warned.


Index: parse.y =================================================================== RCS file: /pub/cvs/ruby/src/ruby/parse.y,v retrieving revision 1.268 diff -u -2 -p -r1.268 parse.y --- parse.y 10 Apr 2003 08:37:12 -0000 1.268 +++ parse.y 17 Apr 2003 02:10:37 -0000 @@ -5197,4 +5203,22 @@ range_op(node) } +static int +literal_node_p(node) + NODE *node; +{ + if (!node) return Qtrue; + switch (nd_type(node)) { + case NODE_LIT: + case NODE_STR: + case NODE_DSTR: + case NODE_EVSTR: + case NODE_DREGX: + case NODE_DREGX_ONCE: + case NODE_DSYM: + return Qtrue; + } + return Qfalse; +} + static NODE* cond0(node) @@ -5207,4 +5231,5 @@ cond0(node) switch (type) { case NODE_DSTR: + case NODE_EVSTR: case NODE_STR: rb_warn("string literal in condition"); @@ -5231,5 +5256,13 @@ cond0(node) else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3); node->nd_cnt = local_append(internal_id()); - warning_unless_e_option("range literal in condition"); + if (e_option_supplied() && RTEST(ruby_verbose)) { + if (literal_node_p(node->nd_beg) || literal_node_p(node->nd_end)) { + rb_warn("range literal in condition"); + } + } + break; + + case NODE_DSYM: + rb_warning("literal in condition"); break;
-- Nobu Nakada