mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
parse.y: remove an extra error message
* parse.y (parse_string): bail out when word-list meets end of input not to show an extra "unexpected" error message after the preceding error. $ ruby -e "%w[" -e:1: unterminated string meets end of file -e:1: syntax error, unexpected terminator, expecting ' ' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c6fb7c1f33
commit
7e68efbc95
3 changed files with 9 additions and 2 deletions
6
parse.y
6
parse.y
|
@ -6009,6 +6009,12 @@ parse_string(struct parser_params *p, rb_strterm_literal_t *quote)
|
||||||
# define unterminated_literal(mesg) compile_error(p, mesg)
|
# define unterminated_literal(mesg) compile_error(p, mesg)
|
||||||
#endif
|
#endif
|
||||||
literal_flush(p, p->lex.pcur);
|
literal_flush(p, p->lex.pcur);
|
||||||
|
if (func & STR_FUNC_QWORDS) {
|
||||||
|
/* no content to add, bailing out here */
|
||||||
|
unterminated_literal("unterminated list meets end of file");
|
||||||
|
p->lex.strterm = 0;
|
||||||
|
return tSTRING_END;
|
||||||
|
}
|
||||||
if (func & STR_FUNC_REGEXP) {
|
if (func & STR_FUNC_REGEXP) {
|
||||||
unterminated_literal("unterminated regexp meets end of file");
|
unterminated_literal("unterminated regexp meets end of file");
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,6 +351,7 @@ class TestParse < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_words
|
def test_words
|
||||||
assert_equal([], %W( ))
|
assert_equal([], %W( ))
|
||||||
|
assert_syntax_error('%w[abc', /unterminated list/)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dstr
|
def test_dstr
|
||||||
|
|
|
@ -888,8 +888,8 @@ eom
|
||||||
bug10957 = '[ruby-core:68477] [Bug #10957]'
|
bug10957 = '[ruby-core:68477] [Bug #10957]'
|
||||||
assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957)
|
assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957)
|
||||||
assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957)
|
assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957)
|
||||||
assert_syntax_error('0..%w.', /unterminated string/, bug10957)
|
assert_syntax_error('0..%q.', /unterminated string/, bug10957)
|
||||||
assert_syntax_error('0...%w.', /unterminated string/, bug10957)
|
assert_syntax_error('0...%q.', /unterminated string/, bug10957)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_too_big_nth_ref
|
def test_too_big_nth_ref
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue