Project

General

Profile

Actions

Bug #17332

closed

No error when using endless method definitions with `self.` setters

Added by hjwylde (Henry Wylde) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0preview1 (2020-09-25 master 0096d2b895) [x86_64-linux]
[ruby-core:100928]

Description

With ruby 3.0.0 preview1, endless method definitions can be used for setter methods with explicit receiver:

def self.foo=() = 1
# => :foo=
obj = Object.new
def obj.foo=() = 1
# => :foo=

From my understanding, setter methods are not intended to be allowed with endless method definitions.

Expected result:
The same error to occur for all setter methods ("setter method cannot be defined in an endless method definition"). E.g.,

def foo=() = 1
# !> SyntaxError ((irb):4: setter method cannot be defined in an endless method definition)
Actions #1

Updated by sawa (Tsuyoshi Sawada) almost 4 years ago

  • Description updated (diff)

Updated by marcandre (Marc-Andre Lafortune) almost 4 years ago

  • Status changed from Open to Closed

Seems to have been fixed since preview1:

[05:29][~]$ ruby -v -e 'def self.foo=() = 1'
ruby 3.0.0dev (2020-11-07T21:47:45Z master 2f12af42f7) [x86_64-darwin18]
-e:1: setter method cannot be defined in an endless method definition
def self.foo=() = 1
[05:29][~]$ ruby -v -e 'obj = Object.new; def obj.foo=() = 1'
ruby 3.0.0dev (2020-11-07T21:47:45Z master 2f12af42f7) [x86_64-darwin18]
-e:1: setter method cannot be defined in an endless method definition
obj = Object.new; def obj.foo=() = 1
Actions

Also available in: Atom PDF

Like0
Like0Like0