Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack trace when source is modified #7

Open
wconrad opened this issue Mar 3, 2015 · 0 comments
Open

Stack trace when source is modified #7

wconrad opened this issue Mar 3, 2015 · 0 comments
Labels

Comments

@wconrad
Copy link
Owner

wconrad commented Mar 3, 2015

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.
@wconrad wconrad added the bug label Mar 3, 2015
@wconrad wconrad changed the title Stack trace when source of q method is modified Stack trace when source is modified Jun 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant