Project

General

Profile

Backport #8375

Lexer error when specific character sequence occurs in string literals

Added by dimitri-lo2u (Dimitri Geshef) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:54846]

Description

The next line causes lexer/parser error:

problematic_string = "#$%"

The error message is: unterminated string meets end of file

The bug occurs in MRI1.9.3... ruby -v = ruby 1.9.3p374 (2013-01-15) [i386-mingw32]

... and in 2.0.0 ruby -v = ruby 2.0.0p0 (2013-02-24) [i386-mingw32]

Associated revisions

Revision 85280f4b
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40607
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

Revision 40607
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

Revision 40607
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

Revision 40607
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

Revision 40607
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

Revision 40607
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].

Revision ecddb967
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40635
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

Revision 40635
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

Revision 40635
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

Revision 40635
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

Revision 40635
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

Revision 40635
Added by nobu (Nobuyoshi Nakada) over 6 years ago

parse.y: invalid name as mere string

  • parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375]

Revision 7fc0105f
Added by nagachika (Tomoyuki Chikanaga) over 6 years ago

merge revision(s) 40606,40607,40635: [Backport #8375]

    test_scanner_events.rb: assert_location

    * test/ripper/test_scanner_events.rb (TestRipper#assert_location):

rename so skipped in backtraces.
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid
name character. [ruby-core:54846] [Bug #8375].

    * parse.y (parser_peek_variable_name): treat invalid global, class,
      and instance variable names as mere strings rather than errors.
      [ruby-core:54885] [Bug #8375]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 69492b4d
Added by usa (Usaku NAKAMURA) about 6 years ago

merge revision(s) 40606,40607,40635: [Backport #8375]

    test_scanner_events.rb: assert_location

    * test/ripper/test_scanner_events.rb (TestRipper#assert_location):

rename so skipped in backtraces.
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid
name character. [ruby-core:54846] [Bug #8375].

    * parse.y (parser_peek_variable_name): treat invalid global, class,
      and instance variable names as mere strings rather than errors.
      [ruby-core:54885] [Bug #8375]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@42462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 42462
Added by usa (Usaku NAKAMURA) about 6 years ago

merge revision(s) 40606,40607,40635: [Backport #8375]

test_scanner_events.rb: assert_location

* test/ripper/test_scanner_events.rb (TestRipper#assert_location):

rename so skipped in backtraces.
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid
name character. [ruby-core:54846] [Bug #8375].

* parse.y (parser_peek_variable_name): treat invalid global, class,
  and instance variable names as mere strings rather than errors.
  [ruby-core:54885] [Bug #8375]

History

Updated by Eregon (Benoit Daloze) over 6 years ago

The complete error is:

$ ruby -e 'problematic_string = "#$%"'
-e:1: syntax error, unexpected $undefined
problematic_string = "#$%"
^
-e:1: unterminated string meets end of file

So this is because it expects a global named $% but this is an invalid global name.

followed by (@@ or @ or $) is interpolating the following variable in double-quoted strings.

It would be nice if the error message could be clearer.

(I personally dislike the special syntax for # (@@ or @ or $) instead of plain #{expr},
it leads to weird cases with $" ($LOADED_FEATURES): "#$" and "#$"").

It can be avoided by using "#\$%" or using simple quotes as '#$%'.

#2

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40607.
Dimitri, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


parse.y: fail if invalid name

  • parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375].
#3

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to nagachika (Tomoyuki Chikanaga)

Updated by matz (Yukihiro Matsumoto) over 6 years ago

I'd like to treat them as mere strings rather than errors.

Matz.

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Assignee changed from nagachika (Tomoyuki Chikanaga) to nobu (Nobuyoshi Nakada)

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Assignee changed from nobu (Nobuyoshi Nakada) to nagachika (Tomoyuki Chikanaga)

add r40635 for backport.

#7

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40650.
Dimitri, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40606,40607,40635: [Backport #8375]

test_scanner_events.rb: assert_location

* test/ripper/test_scanner_events.rb (TestRipper#assert_location):

rename so skipped in backtraces.
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid
name character. [ruby-core:54846] [Bug #8375].

* parse.y (parser_peek_variable_name): treat invalid global, class,
  and instance variable names as mere strings rather than errors.
  [ruby-core:54885] [Bug #8375]

Updated by sakuro (Sakuro OZAWA) about 6 years ago

=begin
# The bug occurs in MRI1.9.3... ruby -v = ruby 1.9.3p374 (2013-01-15) [i386-mingw32]

Is this to be backported to 1.9.3?
=end

#9

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Project changed from Backport200 to Backport193
  • Status changed from Closed to Assigned
  • Assignee changed from nagachika (Tomoyuki Chikanaga) to usa (Usaku NAKAMURA)

Thanks you for your notice! I move this ticket to Backport93.
usa-san will make a judgement about it.

#10

Updated by usa (Usaku NAKAMURA) about 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r42462.
Dimitri, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40606,40607,40635: [Backport #8375]

test_scanner_events.rb: assert_location

* test/ripper/test_scanner_events.rb (TestRipper#assert_location):

rename so skipped in backtraces.
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid
name character. [ruby-core:54846] [Bug #8375].

* parse.y (parser_peek_variable_name): treat invalid global, class,
  and instance variable names as mere strings rather than errors.
  [ruby-core:54885] [Bug #8375]

Also available in: Atom PDF