diff --git a/ChangeLog b/ChangeLog index 01beaed0b2..29b426ec64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Sun Apr 30 22:55:41 2017 Nobuyoshi Nakada + + keep line number after unterminated string literal + + * parse.y (parser_parse_string): keep line number even after an + unterminated string literal. it does not matter in the parser, + ripper needs this value after this error. + + parse.y: unterminated content token + + * parse.y (parser_parse_string): defer the end token to next + reading, to yield tSTRING_CONTENT with the unterminated content. + [Bug #13363] + Sun Apr 30 22:52:38 2017 Marcus Stollsteimer * io.c: [DOC] expand docs for IO#puts diff --git a/parse.y b/parse.y index 88cde7c681..53c09b6a52 100644 --- a/parse.y +++ b/parse.y @@ -6502,16 +6502,14 @@ parser_parse_string(struct parser_params *parser, NODE *quote) pushback(c); if (tokadd_string(func, term, paren, "e->nd_nest, &enc) == -1) { - ruby_sourceline = nd_line(quote); - if (func & STR_FUNC_REGEXP) { - if (parser->eofp) + if (parser->eofp) { + if (func & STR_FUNC_REGEXP) { compile_error(PARSER_ARG "unterminated regexp meets end of file"); - return tREGEXP_END; - } - else { - if (parser->eofp) + } + else { compile_error(PARSER_ARG "unterminated string meets end of file"); - return tSTRING_END; + } + quote->u2.id = -1; } } diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 1b7b56ebfe..8c950041a2 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -109,6 +109,9 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase [[3, 0], :on_heredoc_end, "EOS"] ], Ripper.lex("<<~EOS\n heredoc\nEOS") + assert_equal [[[1, 0], :on_tstring_beg, "'"], + [[1, 1], :on_tstring_content, "foo"]], + Ripper.lex("'foo") end def test_location @@ -131,6 +134,8 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase assert_location %Q["a\nb\r\nc"] assert_location "print(<<""EOS)\nheredoc\nEOS\n" assert_location "print(<<-\"EOS\")\nheredoc\n EOS\n" + assert_location "'foo'" + assert_location "'foo" end def assert_location(src) diff --git a/version.h b/version.h index b54ed9782b..ab104861ec 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.5" #define RUBY_RELEASE_DATE "2017-04-30" -#define RUBY_PATCHLEVEL 307 +#define RUBY_PATCHLEVEL 308 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 4