What text, if any, is allowed on the the line after the =begin and
=end delimiters of block comments?
I have code that looks like this:
p “I work”
and it prints “I work” on these versions of Ruby:
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
ruby 1.9.0 (2008-07-25 revision 18217) [i686-darwin9.5.2]
jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (Java HotSpot™
Client VM 1.5.0_19) [i386-java]
Normally I wouldn’t think about this anymore, but he ruby-parser gem
(2.0.2) throws an error:
embedded document meets end of file. near line 1: "
although it works if you remove the text after the =end.
Based on a cursory grepping of the sources, Ruby 1.9 source
(ruby-1.9.1-p129) never uses any text on the same line as the =begin
or =end delimiters and Rubyspec doesn’t have any tests around block
comments. Rubyspec does have some =begin “Text”, but not =end “Text”
I’d like to fix the ruby-parser gem, but this seems to be something of
a grey area. I’ve never seen anything that requires Ruby to accept or
reject =end Text delimiters on block comments, but the de facto
standard and practice seem to be in conflict. The standard is to
accept text after the =end; the practice seems to be to not do it.