summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y6
-rw-r--r--test/ruby/test_parse.rb1
-rw-r--r--test/ruby/test_syntax.rb4
3 files changed, 9 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 1f7cf2f53f..6c7ca60b46 100644
--- a/parse.y
+++ b/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)
#endif
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) {
unterminated_literal("unterminated regexp meets end of file");
}
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index 1345dabc6e..ea5065960a 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -351,6 +351,7 @@ class TestParse < Test::Unit::TestCase
def test_words
assert_equal([], %W( ))
+ assert_syntax_error('%w[abc', /unterminated list/)
end
def test_dstr
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 3d8f6fb72a..5c1bd8fc16 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -888,8 +888,8 @@ eom
bug10957 = '[ruby-core:68477] [Bug #10957]'
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...%w.', /unterminated string/, bug10957)
+ assert_syntax_error('0..%q.', /unterminated string/, bug10957)
+ assert_syntax_error('0...%q.', /unterminated string/, bug10957)
end
def test_too_big_nth_ref