You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If source code is modified while it is running, cute_print causes a "Method call not found (RuntimeError)" stack trace.
To reproduce
Run this program
require "cute_print"
loop do
ql {1 + 2}
sleep 1
end
While the program is running, edit it. Comment out the "ql" line and save your edits.
This stack trace results:
...
foo.rb:6: (1 + 2) is 3
foo.rb:6: (1 + 2) is 3
/home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/ruby_parser/method_call.rb:17:in `call?': undefined method `[]' for nil:NilClass (NoMethodError)
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/ruby_parser/method_call.rb:13:in `call_to_method?'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/ruby_parser/parsed_code.rb:24:in `method_call_node'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/ruby_parser/parsed_code.rb:18:in `first_call_to_method'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/source_label.rb:21:in `block_code'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/source_label.rb:13:in `to_s'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/formatter.rb:72:in `join'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/formatter.rb:72:in `make_label'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/formatter.rb:65:in `label'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/formatter.rb:32:in `block in write'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/formatter.rb:31:in `write'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/printer.rb:61:in `ql'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/cute_print.rb:54:in `ql'
from /home/wayne/.rvm/gems/ruby-2.2.0/gems/cute_print-1.0.1/lib/cute_print/mixin.rb:18:in `ql'
from /tmp/foo.rb:6:in `block in <main>'
from /tmp/foo.rb:5:in `loop'
from /tmp/foo.rb:5:in `<main>'
Possible fixes
It seems that the parsed source should be cached and so not parsed from source every time. This would cause cute_print to print the right thing even after the source changed, and would generally help performance.
Even with cached source, there is a race condition. In the time between when the program starts running and when it first parses the source, the source could have been changed, moved, etc. cute_print should behave gracefully when it can't parse the source.
The text was updated successfully, but these errors were encountered:
If source code is modified while it is running, cute_print causes a "Method call not found (RuntimeError)" stack trace.
To reproduce
Run this program
While the program is running, edit it. Comment out the "ql" line and save your edits.
This stack trace results:
Possible fixes
The text was updated successfully, but these errors were encountered: