Warn "literal in condition" for __LINE__
Print warning for a code like ```ruby if __LINE__ end # => warning: literal in condition ```
This commit is contained in:
parent
9368782d5c
commit
6ec4d203f7
6
parse.y
6
parse.y
@ -14260,6 +14260,12 @@ cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *l
|
||||
else {
|
||||
SWITCH_BY_COND_TYPE(type, warning, "");
|
||||
}
|
||||
break;
|
||||
|
||||
case NODE_LINE:
|
||||
SWITCH_BY_COND_TYPE(type, warning, "");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1216,6 +1216,9 @@ eom
|
||||
assert_warning(/literal in condition/) do
|
||||
eval('1 if 1')
|
||||
end
|
||||
assert_warning(/literal in condition/) do
|
||||
eval('1 if __LINE__')
|
||||
end
|
||||
assert_warning(/symbol literal in condition/) do
|
||||
eval('1 if :foo')
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user