The same warning for static symbol literal
This commit is contained in:
parent
da139317a5
commit
28392d3045
4
parse.y
4
parse.y
@ -11758,6 +11758,7 @@ cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *l
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_DSYM:
|
case NODE_DSYM:
|
||||||
|
warn_symbol:
|
||||||
SWITCH_BY_COND_TYPE(type, warning, "symbol ")
|
SWITCH_BY_COND_TYPE(type, warning, "symbol ")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -11770,6 +11771,9 @@ cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *l
|
|||||||
node->nd_lit == Qfalse) {
|
node->nd_lit == Qfalse) {
|
||||||
/* booleans are OK, e.g., while true */
|
/* booleans are OK, e.g., while true */
|
||||||
}
|
}
|
||||||
|
else if (SYMBOL_P(node->nd_lit)) {
|
||||||
|
goto warn_symbol;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
SWITCH_BY_COND_TYPE(type, warning, "")
|
SWITCH_BY_COND_TYPE(type, warning, "")
|
||||||
}
|
}
|
||||||
|
@ -1061,16 +1061,16 @@ eom
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_warning_literal_in_condition
|
def test_warning_literal_in_condition
|
||||||
assert_warn(/literal in condition/) do
|
assert_warn(/string literal in condition/) do
|
||||||
eval('1 if ""')
|
eval('1 if ""')
|
||||||
end
|
end
|
||||||
assert_warn(/literal in condition/) do
|
assert_warn(/regex literal in condition/) do
|
||||||
eval('1 if //')
|
eval('1 if //')
|
||||||
end
|
end
|
||||||
assert_warning(/literal in condition/) do
|
assert_warning(/literal in condition/) do
|
||||||
eval('1 if 1')
|
eval('1 if 1')
|
||||||
end
|
end
|
||||||
assert_warning(/literal in condition/) do
|
assert_warning(/symbol literal in condition/) do
|
||||||
eval('1 if :foo')
|
eval('1 if :foo')
|
||||||
end
|
end
|
||||||
assert_warning(/symbol literal in condition/) do
|
assert_warning(/symbol literal in condition/) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user