Warn on ... at EOL

This commit is contained in:
Nobuyoshi Nakada 2019-11-12 17:14:10 +09:00
parent d1ae2bc27f
commit a58b4eee25
No known key found for this signature in database
GPG Key ID: 4BC7D6DF58D8DF60
2 changed files with 10 additions and 0 deletions

View File

@ -9235,6 +9235,9 @@ parser_yylex(struct parser_params *p)
switch (c = nextc(p)) {
case '.':
if ((c = nextc(p)) == '.') {
if (p->lex.paren_nest == 0 && looking_at_eol_p(p)) {
rb_warn0("... at EOL, should be parenthesized?");
}
return is_beg ? tBDOT3 : tDOT3;
}
pushback(p, c);

View File

@ -986,6 +986,13 @@ eom
assert_syntax_error('0...%q.', /unterminated string/, bug10957)
end
def test_range_at_eol
assert_warn(/\.\.\. at EOL/) {eval("1...\n2")}
assert_warn('') {eval("(1...)")}
assert_warn('') {eval("(1...\n2)")}
assert_warn('') {eval("{a: 1...\n2}")}
end
def test_too_big_nth_ref
bug11192 = '[ruby-core:69393] [Bug #11192]'
assert_warn(/too big/, bug11192) do