Skip to content

Wrong line number reported in backtrace in hash creation #4154

@dymaxionuk

Description

@dymaxionuk

Environment

ruby 2.3.0p0 (2015-12-25 revision 53290) [i386-mingw32]
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) Client VM 25.31-b07 on 1.8.0_31-b13 +jit [mswin32-x86]
$ systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 7 Enterprise
OS Version:                6.1.7601 Service Pack 1 Build 7601

Expected Behavior

Correct line number is reported in backtrace when raising error in function called within hash creation statement.

Example code:

$ cat rubyexample.rb
def mfunc(hash)
   hash.size
end

def a_func
   raise StandardError, "Blah"
end

mfunc(
  {
    :a => 1,
    :b => 2,
    :variab => a_func
  }
)

Actual Behavior

Output in MRI 2.3.0

$ ruby rubyexample.rb
rubyexample.rb:6:in `a_func': Blah (StandardError)
        from rubyexample.rb:13:in `<main>'

Output in JRuby

$ jruby rubyexample.rb
StandardError: Blah
  a_func at rubyexample.rb:6
   <top> at rubyexample.rb:9

Cross referencing another linenum issue: #4211

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions