Projects

Ticket #888 (new defect)

Opened 17 months ago

Last modified 14 months ago

Compiled MacRuby can't read the DATA const for the text after __END__ in the source

Reported by: dev@… Owned by: lsansonetti@…
Priority: major Milestone: MacRuby Later
Component: MacRuby Keywords:
Cc: dev@…

Description

$ cat foo.rb
#!/usr/bin/env macruby
puts DATA.read
__END__
lolcats

$ macruby foo.rb 
lolcats

$ macrubyc foo.rb -o foo

$ ./foo
uninitialized constant DATA (NameError)

Change History

Changed 17 months ago by dev@…

  • cc dev@… added

Cc Me!

Changed 17 months ago by lsansonetti@…

  • milestone MacRuby 0.7 deleted

That's a problem. DATA is supposed to be a File object seeked to the end of the source file. I am not sure we really want to preserve this during AOT compilation.

Changed 17 months ago by dev@…

Hum, I didn't know about this implementation detail. But so it is. You can even rewind it and read the whole source.

It may not make sense indeed, since the source is (sometimes on purpose) gone after compilation, and bunch of files may be linked together.

Maybe make the string after END available through some other means? Or just tell programmers not to use the data section in compiled programs?

In case of the latter, at least an attempt to access DATA should have a more meaningful error. Maybe provide an object in the DATA constant, but any attempt to call a method on it will raise and explain that DATA is unavailable to compiled code.

Changed 14 months ago by lsansonetti@…

  • milestone set to MacRuby Later

For Later.

Note: See TracTickets for help on using tickets.