Bug #5966

->{} doesn't work in BasicObject

Added by ktsj (Kazuki Tsujimoto) 4 months ago. Updated 3 months ago.

[ruby-core:42349]
Status:Closed Start date:02/04/2012
Priority:Normal Due date:
Assignee:ko1 (Koichi Sasada) % Done:

100%

Category:core
Target version:2.0.0
ruby -v:ruby 2.0.0dev (2012-02-03 trunk 34424) [x86_64-linux]

Description

$ ./ruby -ve 'BasicObject.new.instance_eval { ->{} }'
ruby 2.0.0dev (2012-02-03 trunk 34424) [x86_64-linux]
-e:1:in `block in <main>': undefined method `lambda' for #<BasicObject:0x007ffff847ef28> (NoMethodError)
        from -e:1:in `instance_eval'
        from -e:1:in `<main>'

I'm not sure it is a bug or not, but I think lambda syntax should work everywhere.

0001-Bug-5966-lambda-in-BasicObject.patch (2.4 kB) nobu (Nobuyoshi Nakada), 02/11/2012 06:56 am

Associated revisions

Revision 34819
Added by nobu (Nobuyoshi Nakada) 3 months ago

* compile.c (iseq_compile_each): call on special object instead of self. since stabby lambda is a syntax, so it should not be affected by the context. [ruby-core:42349][Bug #5966] * insns.def (send): no special deal for FCALL. self should be put on TOS instead.

History

Updated by nobu (Nobuyoshi Nakada) 3 months ago

I'm not sure why FCALL is dealt specially in op_send. It doesn't seem needed if self is put instead of nil.

Updated by ko1 (Koichi Sasada) 3 months ago

Hi, (2012/02/11 6:56), Nobuyoshi Nakada wrote: > File 0001-Bug-5966-lambda-in-BasicObject.patch added > Status changed from Open to Assigned > Assignee set to Koichi Sasada Thank you. Please commit it. > I'm not sure why FCALL is dealt specially in op_send. > It doesn't seem needed if self is put instead of nil. It is a historical reason. No reason now. -- // SASADA Koichi at atdot dot net

Updated by nobu (Nobuyoshi Nakada) 3 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r34819. Kazuki, thank you for reporting this issue. Your contribution to Ruby is greatly appreciated. May Ruby be with you. ---------- * compile.c (iseq_compile_each): call on special object instead of self. since stabby lambda is a syntax, so it should not be affected by the context. [ruby-core:42349][Bug #5966] * insns.def (send): no special deal for FCALL. self should be put on TOS instead.

Also available in: Atom PDF