From: "jeremyevans0 (Jeremy Evans)" Date: 2022-08-24T21:03:08+00:00 Subject: [ruby-core:109673] [Ruby master Bug#18974] Wrong line number in the rescue iseq for the exception matching code Issue #18974 has been updated by jeremyevans0 (Jeremy Evans). I've submitted a pull request to fix this issue: https://github.com/ruby/ruby/pull/6283 ---------------------------------------- Bug #18974: Wrong line number in the rescue iseq for the exception matching code https://bugs.ruby-lang.org/issues/18974#change-98897 * Author: hurricup (Alexandr Evstigneev) * Status: Open * Priority: Normal * ruby -v: 2.7.5,3.1.2 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Script for demonstration: ``` def foo begin raise 'error' rescue => e puts e.message end end puts RubyVM::InstructionSequence.of(method :foo).disasm ``` Disasm for the catch table: ``` | catch type: rescue st: 0000 ed: 0005 sp: 0000 cont: 0006 | == disasm: # (catch: TRUE) | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) | [ 1] $!@0 | 0000 getlocal_WC_0 $!@0 ( 5)[Li] | 0002 putobject StandardError | 0004 checkmatch 3 | 0006 branchunless 20 | 0008 getlocal_WC_0 $!@0 ( 4) | 0010 setlocal_WC_1 e@0 | 0012 putself ( 5) | 0013 getlocal_WC_1 e@0 | 0015 opt_send_without_block | 0017 opt_send_without_block | 0019 leave | 0020 getlocal_WC_0 $!@0 | 0022 throw 0 | catch type: retry st: 0005 ed: 0006 sp: 0000 cont: 0000 |------------------------------------------------------------------------ ``` For some reason first instruction info has line 5, instead of 4. If `rescue` block is empty, line number is correct. The user story is: when debugging and put bp at line 5, it triggers on the first instruction and `e` is not yet initialized and can't be inspected. This is confusing. -- https://bugs.ruby-lang.org/ Unsubscribe: