Project

General

Profile

Actions

Bug #19631

open

module_eval does not propulate absolute_path for Kernel.caller_locations

Added by daveola (David Stellar) about 1 year ago. Updated 3 days ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
[ruby-core:113410]

Description

I am using module_eval and noticing that since ruby 3.2 the Kernel locations do not have absolute_path for any of the eval code, though the path is available. This is a regression since at least ruby 3.0 which still works.

I am on 3.2.2, and here is some sample code:

class Script < Module
  script = %q{
    def self.locations
      Kernel.caller_locations.each { |loc|
        puts "LOCATION: #{loc}"
        puts "ABSPATH:  #{loc.absolute_path}"
        puts "PATH:     #{loc.path}"
      }
    end
    self.locations
  }

  module_eval(script, "/this/is/my/path", 0)
end

The output for the code at the top of the caller locations (inside the module_eval) is:

LOCATION: /this/is/my/path:9:in '<class:Script>'              
ABSPATH:                       
PATH:     /this/is/my/path

But the absolute_path should have the correct path data as well

Actions #1

Updated by daveola (David Stellar) about 1 year ago

  • Description updated (diff)
Actions #2

Updated by daveola (David Stellar) about 1 year ago

  • Description updated (diff)

Updated by Annih (Baptiste Courtois) 3 days ago

daveola (David Stellar) wrote:

I am using module_eval and noticing that since ruby 3.2 the Kernel locations do not have absolute_path for any of the eval code, though the path is available. This is a regression since at least ruby 3.0 which still works.

I am on 3.2.2:

I confirm I can reproduce on 3.1.3

Actions

Also available in: Atom PDF

Like1
Like0Like0Like0