Skip to content

Instantly share code, notes, and snippets.

@rkh
Created December 16, 2008 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkh/36765 to your computer and use it in GitHub Desktop.
Save rkh/36765 to your computer and use it in GitHub Desktop.
>> def foo; bar = "blah"; raise NotImplementedError; end
=> #<CompiledMethod foo file=(irb)>
>> def get_exception; begin; yield; nil; rescue Exception => e; e; end; end
=> #<CompiledMethod get_exception file=(irb)>
>> e = get_exception { foo }
=> #<NotImplementedError: NotImplementedError>
>> cx = e.context
=> #<MethodContext:0x16a main#foo (irb):1>
>> m = cx.method
=> #<CompiledMethod foo file=(irb)>
>> m.local_names
=> #<Tuple: :bar>
>> cx.get_eval_local :bar
=> nil
Shouldn't the last line return "blah"??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment