Project

General

Profile

Actions

Bug #10586

closed

function wrongly returns nil in eval()

Added by tmpvar (Daisuke Kobayashi) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p598 (2014-11-13) [x86_64-cygwin]
[ruby-core:66773]

Description

In the following code, function returns nil in eval().
Getting rid of the last line, it returns 1 as we expect.

def foo; 1; end
p foo #=> 1
eval 'p foo' #=> nil (NG,expect=1)
foo=1 #<- bug trigger

Files

code1.rb (244 Bytes) code1.rb Reproducible code (using attr_reader) tmpvar (Daisuke Kobayashi), 12/11/2014 03:56 AM
code2.rb (126 Bytes) code2.rb Reproducible code (as in Description) tmpvar (Daisuke Kobayashi), 12/11/2014 03:56 AM

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected

foo is a local variable.

Actions

Also available in: Atom PDF

Like0
Like0