summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-05-28 12:21:25 -0400
committerKevin Newton <[email protected]>2024-05-28 13:12:21 -0400
commitfd95ba255a413ff02cdc542dd16a2e2901387fc6 (patch)
tree535c07117e2d4632ad3779383ba7465a60926470 /compile.c
parent8f84fbbf968a43c44b34ada601cf2b4a0bfa9d54 (diff)
Make ensure first lineno the first line of the ensure
Previously, ensure ISEQs took their first line number from the line number coming from the AST. However, if this is coming from an empty `begin`..`end` inside of a method, this can be all of the way back to the method declaration. Instead, this commit changes it to be the first line number of the ensure block itself. The first_lineno field is only accessible through manual ISEQ compilation or through tracepoint. Either way, this will be more accurate for targeting going forward.
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 5fa35512c2..3438d6a9fa 100644
--- a/compile.c
+++ b/compile.c
@@ -8343,7 +8343,7 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
static int
compile_ensure(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- const int line = nd_line(node);
+ const int line = nd_line(RNODE_ENSURE(node)->nd_ensr);
const NODE *line_node = node;
DECL_ANCHOR(ensr);
const rb_iseq_t *ensure = NEW_CHILD_ISEQ(RNODE_ENSURE(node)->nd_ensr,