Issue #8375 has been updated by Eregon (Benoit Daloze).


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 '#$%'.
----------------------------------------
Bug #8375: Lexer error when specific character sequence occurs in string literals
https://bugs.ruby-lang.org/issues/8375#change-39176

Author: dimitri-lo2u (Dimitri Geshef)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p0 (2013-02-24) [i386-mingw32]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


# 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]


-- 
http://bugs.ruby-lang.org/