ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias
@ 2021-03-16 17:26 josh
  2021-03-16 17:34 ` [ruby-core:102885] " josh
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: josh @ 2021-03-16 17:26 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been reported by joshuadreed (Josh Reed).

----------------------------------------
Bug #17725: Prepend Breaks Ability to Alias
https://bugs.ruby-lang.org/issues/17725

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102885] [Ruby master Bug#17725] Prepend Breaks Ability to Alias
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
@ 2021-03-16 17:34 ` josh
  2021-03-16 18:15 ` [ruby-core:102886] " josh
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: josh @ 2021-03-16 17:34 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by joshuadreed (Josh Reed).








``` ruby
module Dummy; end
class Foo
  def ten
    10
  end
end

Foo.prepend(Dummy)
class Foo
  alias_method(:old_ten, :ten)
  def ten
    puts 'blah blah'
    old_ten
  end
end

Foo.new.ten

> blah blah

```

Okay, doesn't seem to affect *every* class.

I do suspect it may be to do with refinement, so I will check into that next.

----------------------------------------
Bug #17725: Prepend Breaks Ability to Alias
https://bugs.ruby-lang.org/issues/17725#change-90945

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102886] [Ruby master Bug#17725] Prepend Breaks Ability to Alias
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
  2021-03-16 17:34 ` [ruby-core:102885] " josh
@ 2021-03-16 18:15 ` josh
  2021-03-16 18:47 ` [ruby-core:102887] " josh
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: josh @ 2021-03-16 18:15 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by joshuadreed (Josh Reed).


So, I set out to test my hypothesis regarding refinements. I've never used refinements prior to this, so it's still possible there's an interaction somewhere, but at least not in the way I was thinking.

``` ruby
module Dummy; end

class Foo
  def ten
    10
  end
end

module Bar
  refine Foo do
    def ten
      11
    end
  end
end

class Baz
  using Bar
  def check
    Foo.new.ten
  end
end

Baz.prepend(Dummy)

class Baz
  alias_method(:old_check, :check)
  def check
    puts 'blah blah'
    old_check
  end
end

p Baz.new.check

>blah blah
>11
```



----------------------------------------
Bug #17725: Prepend Breaks Ability to Alias
https://bugs.ruby-lang.org/issues/17725#change-90946

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102887] [Ruby master Bug#17725] Prepend Breaks Ability to Alias
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
  2021-03-16 17:34 ` [ruby-core:102885] " josh
  2021-03-16 18:15 ` [ruby-core:102886] " josh
@ 2021-03-16 18:47 ` josh
  2021-03-17  1:09 ` [ruby-core:102895] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods nobu
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: josh @ 2021-03-16 18:47 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by joshuadreed (Josh Reed).


One more detail.

``` ruby 
module Dummy; end
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end


String.prepend(Dummy)

class String
  alias_method(:old_plus2, :+)
  def + other
    puts 'blah blah2'
    old_plus2(other)
  end
end

'a' + 'b'
```

If the method was aliased prior to prepending, the method is perfectly re-alias-able.

----------------------------------------
Bug #17725: Prepend Breaks Ability to Alias
https://bugs.ruby-lang.org/issues/17725#change-90947

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102895] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (2 preceding siblings ...)
  2021-03-16 18:47 ` [ruby-core:102887] " josh
@ 2021-03-17  1:09 ` nobu
  2021-03-17  1:15 ` [ruby-core:102896] " nobu
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2021-03-17  1:09 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by nobu (Nobuyoshi Nakada).

Subject changed from Prepend Breaks Ability to Alias to Prepend breaks ability to override optimized methods

Alias is not concerned.

```ruby
# bug-17725.rb
String.prepend(Module.new) unless ARGV.empty?
class String
  def + other
    'blah blah'
  end
end

p 'a' + 'b'
```

```sh
$ ruby bug-17725.rb 
"blah blah"

$ ruby bug-17725.rb 1
"ab"
```

Seems the redefinition flag is not set by prepend.

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-90955

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102896] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (3 preceding siblings ...)
  2021-03-17  1:09 ` [ruby-core:102895] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods nobu
@ 2021-03-17  1:15 ` nobu
  2021-03-17  1:24 ` [ruby-core:102897] " nobu
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2021-03-17  1:15 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by nobu (Nobuyoshi Nakada).


nobu (Nobuyoshi Nakada) wrote in #note-4:
> Seems the redefinition flag is not set by prepend.

This is not accurate, actual method owner class needs to be checked too.

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-90957

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102897] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (4 preceding siblings ...)
  2021-03-17  1:15 ` [ruby-core:102896] " nobu
@ 2021-03-17  1:24 ` nobu
  2021-03-18  4:35 ` [ruby-core:102911] " xtkoba+ruby
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2021-03-17  1:24 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by nobu (Nobuyoshi Nakada).


Hmmmm?

```
$ ruby -v
ruby 3.1.0dev (2021-03-16T15:19:37Z master a47697aa44) [x86_64-darwin19]

$ ruby --enable=gems ../bug/bug-17725.rb 
"blah blah"

$ ruby --enable=gems ../bug/bug-17725.rb 1
"ab"

$ ruby --disable=gems ../bug/bug-17725.rb
"blah blah"

$ ruby --disable=gems ../bug/bug-17725.rb 1
"blah blah"
```


----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-90958

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102911] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (5 preceding siblings ...)
  2021-03-17  1:24 ` [ruby-core:102897] " nobu
@ 2021-03-18  4:35 ` xtkoba+ruby
  2021-03-20  6:42 ` [ruby-core:102951] " xtkoba+ruby
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: xtkoba+ruby @ 2021-03-18  4:35 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by xtkoba (Tee KOBAYASHI).


FWIW,
```ruby
# bug17725-test.rb
eval <<EOS
# encoding: ascii-8bit
MY_STRING = ''
EOS

MY_STRING + ''

String.prepend(Module.new)
class String
  def + other
    'blah blah'
  end
end

p 'a' + 'b'
```
gives
```
$ ruby --disable-gems bug17725-test.rb
"ab"
```


----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-90975

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:102951] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (6 preceding siblings ...)
  2021-03-18  4:35 ` [ruby-core:102911] " xtkoba+ruby
@ 2021-03-20  6:42 ` xtkoba+ruby
  2021-04-09 22:10 ` [ruby-core:103358] " merch-redmine
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: xtkoba+ruby @ 2021-03-20  6:42 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by xtkoba (Tee KOBAYASHI).


Another example:
```ruby
'' != nil

module Blah
  def == other
    'blah blah'
  end
end
String.prepend(Blah)

p 'a' == 'b' # => false
```

It seems that `rb_vm_check_redefinition_opt_method` is not working correctly in these cases. If the issue were only with `String#==` and `String#+`, a (dirty) workaround would be as follows:
```
--- a/vm.c
+++ b/vm.c
@@ -1854,6 +1854,12 @@ rb_vm_check_redefinition_opt_method(cons
 
 	    ruby_vm_redefined_flag[bop] |= flag;
 	}
+	else if (me->def->body.iseq.iseqptr == (rb_iseq_t *)rb_str_equal) {
+	    ruby_vm_redefined_flag[BOP_EQ] |= STRING_REDEFINED_OP_FLAG;
+	}
+	else if (me->def->body.iseq.iseqptr == (rb_iseq_t *)rb_str_plus) {
+	    ruby_vm_redefined_flag[BOP_PLUS] |= STRING_REDEFINED_OP_FLAG;
+	}
     }
 }
 
```

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-91016

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:103358] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (7 preceding siblings ...)
  2021-03-20  6:42 ` [ruby-core:102951] " xtkoba+ruby
@ 2021-04-09 22:10 ` merch-redmine
  2021-08-01  9:27 ` [ruby-core:104738] " nagachika00
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: merch-redmine @ 2021-04-09 22:10 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by jeremyevans0 (Jeremy Evans).


I've submitted a pull request to fix this: https://github.com/ruby/ruby/pull/4376

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-91449

* Author: joshuadreed (Josh Reed)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:104738] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (8 preceding siblings ...)
  2021-04-09 22:10 ` [ruby-core:103358] " merch-redmine
@ 2021-08-01  9:27 ` nagachika00
  2021-11-24 15:04 ` [ruby-core:106266] " mk
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: nagachika00 @ 2021-08-01  9:27 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by nagachika (Tomoyuki Chikanaga).


I think fa0279d947c3962c3f8c32852278d3ebb964cb19 should be backported too.

But it could introduce a tiny incompatibility. I'd like to investigate the another workarounds of the issue.

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-93074

* Author: joshuadreed (Josh Reed)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:106266] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (9 preceding siblings ...)
  2021-08-01  9:27 ` [ruby-core:104738] " nagachika00
@ 2021-11-24 15:04 ` mk
  2021-12-24  5:54 ` [ruby-core:106801] " nagachika (Tomoyuki Chikanaga)
  2021-12-24  9:05 ` [ruby-core:106805] " nagachika (Tomoyuki Chikanaga)
  12 siblings, 0 replies; 14+ messages in thread
From: mk @ 2021-11-24 15:04 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by mk (Matthias Käppler).


@nagachika @ko1 I noticed neither commit appears to be included in 3.0.3. Just wondering why? We currently need to build a patched 3.0.2 image that includes these two commits since we were running into this problem, and it has been working fine for us.

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-94887

* Author: joshuadreed (Josh Reed)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:106801] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (10 preceding siblings ...)
  2021-11-24 15:04 ` [ruby-core:106266] " mk
@ 2021-12-24  5:54 ` nagachika (Tomoyuki Chikanaga)
  2021-12-24  9:05 ` [ruby-core:106805] " nagachika (Tomoyuki Chikanaga)
  12 siblings, 0 replies; 14+ messages in thread
From: nagachika (Tomoyuki Chikanaga) @ 2021-12-24  5:54 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED

I gave up to find a workaround. I will backport fb4cf204a662a8cd9dafef6f31f2bd0db9129abe and fa0279d947c3962c3f8c32852278d3ebb964cb19 even though they introduce an incompatibility. I believe the incompatibility (the Array#size is going to have an independent method entry instead of being defined as the alias of Array#length) couldn't cause any problem in the real world applications...

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-95610

* Author: joshuadreed (Josh Reed)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:106805] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods
  2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
                   ` (11 preceding siblings ...)
  2021-12-24  5:54 ` [ruby-core:106801] " nagachika (Tomoyuki Chikanaga)
@ 2021-12-24  9:05 ` nagachika (Tomoyuki Chikanaga)
  12 siblings, 0 replies; 14+ messages in thread
From: nagachika (Tomoyuki Chikanaga) @ 2021-12-24  9:05 UTC (permalink / raw)
  To: ruby-core

Issue #17725 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE

ruby_3_0 545d6820715a48a17d6182128c0db4198dfa76c1 merged revision(s) fb4cf204a662a8cd9dafef6f31f2bd0db9129abe,fa0279d947c3962c3f8c32852278d3ebb964cb19.

----------------------------------------
Bug #17725: Prepend breaks ability to override optimized methods
https://bugs.ruby-lang.org/issues/17725#change-95614

* Author: joshuadreed (Josh Reed)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE
----------------------------------------
Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` 

As an example:
``` ruby
module Dummy; end
# String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

> blah blah
```

``` ruby
module Dummy; end
String.prepend(Dummy)
class String
  alias_method(:old_plus, :+)
  def + other
    puts 'blah blah'
    old_plus(other)
  end
end

'a' + 'b'

>
```

Prepending after an `alias` does not affect the previous `alias`



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-12-24  9:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 17:26 [ruby-core:102884] [Ruby master Bug#17725] Prepend Breaks Ability to Alias josh
2021-03-16 17:34 ` [ruby-core:102885] " josh
2021-03-16 18:15 ` [ruby-core:102886] " josh
2021-03-16 18:47 ` [ruby-core:102887] " josh
2021-03-17  1:09 ` [ruby-core:102895] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods nobu
2021-03-17  1:15 ` [ruby-core:102896] " nobu
2021-03-17  1:24 ` [ruby-core:102897] " nobu
2021-03-18  4:35 ` [ruby-core:102911] " xtkoba+ruby
2021-03-20  6:42 ` [ruby-core:102951] " xtkoba+ruby
2021-04-09 22:10 ` [ruby-core:103358] " merch-redmine
2021-08-01  9:27 ` [ruby-core:104738] " nagachika00
2021-11-24 15:04 ` [ruby-core:106266] " mk
2021-12-24  5:54 ` [ruby-core:106801] " nagachika (Tomoyuki Chikanaga)
2021-12-24  9:05 ` [ruby-core:106805] " nagachika (Tomoyuki Chikanaga)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).