pry / pry-stack_explorer

Walk the stack in a Pry session
Other
454 stars 28 forks source link

Fix annoying warning on nil bindings. #25

Closed am-kantox closed 4 years ago

am-kantox commented 9 years ago

Sometimes in Rails console I got an annoying error message on nil bindings. This is to safely eliminate them.

kyrylo commented 9 years ago

Hi! Why not just quick return if the b's are nil? That expression is already very complex.

kyrylo commented 9 years ago

It would be nice to have a unit test for that as well. I'm also just curious what kind of messages do you get? Could you show some of them?

am-kantox commented 9 years ago

Obviously I get NoMethodError: private method 'eval' called for nil:NilClass on nils. Unfortunately, I can barely say under what conditions/circumstances it happens. I will provide the unit test for that, though the change seem too obvious to require an explicit unit test.

am-kantox commented 9 years ago

Apparently during test writing I met the weird behaviour on [likely] same bindings considered non equal. Please refer to the commented lines in test/test_stack_explorer.rb for details. I blame VirtualBox, I run tests on.

kyrylo commented 9 years ago

The problem is that when we compare local variables in #bindings_equal?, we compare 2 different empty arrays, hence #equal? returns false.

am-kantox commented 9 years ago

I finally fixed that as well. It sounds being a bug to me, since new arrays were always created, forcing #bindings_equal? to return false constantly, despite whether bindings were in fact equal.

joallard commented 4 years ago

Hi, is this still current? I'll temporarily close this, but let me know if this is still useful. Thanks!