Project

General

Profile

Actions

Bug #13939

closed

Ruby 2.4.2 has issue supporting Seattle.rb style for define_method

Added by danielpclark (Daniel P. Clark) about 4 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
[ruby-core:82999]

Description

In Ruby 2.3 & 2.4.0 you can do this

define_method :some_method_name { "asdf" }

As of my trying 2.4.2 this is no longer supported. Anyone who tries to load my 'read_source' gem will get a failure message in require without explaining the specific area of code.

SyntaxError: /home/danielpclark/dev/read_source/test/support/example.rb:18: syntax error, unexpected '{', expecting keyword_end
ethod :also_attr_method_name { "asdf" }
                              ^
/home/danielpclark/dev/read_source/test/support/example.rb:18: syntax error, unexpected '}', expecting keyword_end
so_attr_method_name { "asdf" }
                              ^
    from (irb):2:in `require_relative'
    from (irb):2
    from /usr/share/rvm/rubies/ruby-2.4.2/bin/irb:11:in `<main>'

To fix my gem for Ruby 2.4.2 I now have to wrap the method name in parenthesis ()

define_method(:some_method_name) { "asdf" }

And that will work. But I find this odd as the following will still work in 2.4.2:

define_method :johny, instance_method(:apple)

Which is still Seattle.rb style.


Related issues

Is duplicate of Ruby master - Bug #13898: Block parsing regressionRejectedActions
Has duplicate Ruby master - Bug #13976: SyntaxError if curly brace block follows args without parentheses, introduced in 2.4.2ClosedActions
Actions

Also available in: Atom PDF