ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:99242] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestor
@ 2020-07-20 23:04 XrXr
  2020-07-21  0:50 ` [ruby-core:99244] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors merch-redmine
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: XrXr @ 2020-07-20 23:04 UTC (permalink / raw
  To: ruby-core

Issue #17038 has been reported by alanwu (Alan Wu).

----------------------------------------
Bug #17038: On master, ancestry edits can lead to duplicates in Module#ancestor
https://bugs.ruby-lang.org/issues/17038

* Author: alanwu (Alan Wu)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-20T06:39:31Z master 935d0b3d05) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Running the following [script](https://wandbox.org/permlink/0f48S2QhvEO1cOBF) on master(935d0b3d05dfc8b30bba505792129bf0e33ebe3b),
`A` appears three times in the lookup chain of `C` and `A#foo` is called multiple
times with `super`.

```ruby
module A
  def foo
    [:a] + super
  end
end

module B
  def foo
    [:b] + super
  end
end

class Object
  def foo
    [:object]
  end
end

module C
  def foo
    [:c] + super
  end
end

class D
  prepend A
  include C
  include B


  def foo
    [:d] + super
  end
end

B.include A
C.include A

p D.ancestors
p D.new.foo
p RUBY_REVISION

__END__

[A, D, B, A, C, A, Object, Kernel, BasicObject]
[:a, :d, :b, :a, :c, :a, :object]
"935d0b3d05dfc8b30bba505792129bf0e33ebe3b"
```

This change was introduced in #9573. Is this behavior intentional?
In my opinion it's a bit odd since it's not possible to have duplicates
in the lookup chain on released versions. Allowing duplicates can
surprise peopole that are used to not having duplicates and lead to bugs.
If `A#foo` had side effects, for example, calling it multiple times
could be undesirable.

Also, logically it doesn't make sense to have a module be the ancestor of itself.
Comparison operators make less sense with this new setup.



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

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

* [ruby-core:99244] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors
  2020-07-20 23:04 [ruby-core:99242] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestor XrXr
@ 2020-07-21  0:50 ` merch-redmine
  2020-07-21  2:25 ` [ruby-core:99245] " marcandre-ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: merch-redmine @ 2020-07-21  0:50 UTC (permalink / raw
  To: ruby-core

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


I believe it's always been possible to have duplicates in ancestors, even before this change:

```ruby
class A
end
class B < A
end
module C
end
B.include C
A.include C
B.ancestors
# => [B, C, A, C, Object, Kernel, BasicObject]
```

Making include/prepend affect iclasses certainly makes duplicates in ancestors more likely, though.

I don't think this is a bug.  If you think it is a bug, can you describe what you consider the correct behavior to be?

----------------------------------------
Bug #17038: On master, ancestry edits can lead to duplicates in Module#ancestors
https://bugs.ruby-lang.org/issues/17038#change-86628

* Author: alanwu (Alan Wu)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-20T06:39:31Z master 935d0b3d05) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Running the following [script](https://wandbox.org/permlink/0f48S2QhvEO1cOBF) on master(935d0b3d05dfc8b30bba505792129bf0e33ebe3b),
`A` appears three times in the lookup chain of `C` and `A#foo` is called multiple
times with `super`.

```ruby
module A
  def foo
    [:a] + super
  end
end

module B
  def foo
    [:b] + super
  end
end

class Object
  def foo
    [:object]
  end
end

module C
  def foo
    [:c] + super
  end
end

class D
  prepend A
  include C
  include B


  def foo
    [:d] + super
  end
end

B.include A
C.include A

p D.ancestors
p D.new.foo
p RUBY_REVISION

__END__

[A, D, B, A, C, A, Object, Kernel, BasicObject]
[:a, :d, :b, :a, :c, :a, :object]
"935d0b3d05dfc8b30bba505792129bf0e33ebe3b"
```

This change was introduced in #9573. Is this behavior intentional?
In my opinion it's a bit odd since it's not possible to have duplicates
in the lookup chain on released versions. Allowing duplicates can
surprise peopole that are used to not having duplicates and lead to bugs.
If `A#foo` had side effects, for example, calling it multiple times
could be undesirable.

Also, logically it doesn't make sense to have a module be the ancestor of itself.
Comparison operators make less sense with this new setup.



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

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

* [ruby-core:99245] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors
  2020-07-20 23:04 [ruby-core:99242] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestor XrXr
  2020-07-21  0:50 ` [ruby-core:99244] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors merch-redmine
@ 2020-07-21  2:25 ` marcandre-ruby-core
  2020-07-21  3:23 ` [ruby-core:99246] " XrXr
  2020-07-21 14:56 ` [ruby-core:99252] " marcandre-ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: marcandre-ruby-core @ 2020-07-21  2:25 UTC (permalink / raw
  To: ruby-core

Issue #17038 has been updated by marcandre (Marc-Andre Lafortune).


I imagine that @alanwu feels the example code should behave the same way if the `include` were done sooner or later.

Jeremy Evans is right, the issue has existed for a long time.

I would prefer if we could always include a module multiple times (at different levels).

See this discussion: https://bugs.ruby-lang.org/issues/1586


----------------------------------------
Bug #17038: On master, ancestry edits can lead to duplicates in Module#ancestors
https://bugs.ruby-lang.org/issues/17038#change-86629

* Author: alanwu (Alan Wu)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-20T06:39:31Z master 935d0b3d05) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Running the following [script](https://wandbox.org/permlink/0f48S2QhvEO1cOBF) on master(935d0b3d05dfc8b30bba505792129bf0e33ebe3b),
`A` appears three times in the lookup chain of `C` and `A#foo` is called multiple
times with `super`.

```ruby
module A
  def foo
    [:a] + super
  end
end

module B
  def foo
    [:b] + super
  end
end

class Object
  def foo
    [:object]
  end
end

module C
  def foo
    [:c] + super
  end
end

class D
  prepend A
  include C
  include B


  def foo
    [:d] + super
  end
end

B.include A
C.include A

p D.ancestors
p D.new.foo
p RUBY_REVISION

__END__

[A, D, B, A, C, A, Object, Kernel, BasicObject]
[:a, :d, :b, :a, :c, :a, :object]
"935d0b3d05dfc8b30bba505792129bf0e33ebe3b"
```

This change was introduced in #9573. Is this behavior intentional?
In my opinion it's a bit odd since it's not possible to have duplicates
in the lookup chain on released versions. Allowing duplicates can
surprise peopole that are used to not having duplicates and lead to bugs.
If `A#foo` had side effects, for example, calling it multiple times
could be undesirable.

Also, logically it doesn't make sense to have a module be the ancestor of itself.
Comparison operators make less sense with this new setup.



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

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

* [ruby-core:99246] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors
  2020-07-20 23:04 [ruby-core:99242] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestor XrXr
  2020-07-21  0:50 ` [ruby-core:99244] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors merch-redmine
  2020-07-21  2:25 ` [ruby-core:99245] " marcandre-ruby-core
@ 2020-07-21  3:23 ` XrXr
  2020-07-21 14:56 ` [ruby-core:99252] " marcandre-ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: XrXr @ 2020-07-21  3:23 UTC (permalink / raw
  To: ruby-core

Issue #17038 has been updated by alanwu (Alan Wu).


> I believe it's always been possible to have duplicates in ancestors, even before this change

Thank you for the example; I stand corrected. I made the ticket because I thought we were introducing
brand new potential failure modes into user code. It's not a concern, it looks like.
I don't really have a preference for whether duplicates should be allowed or not.



----------------------------------------
Bug #17038: On master, ancestry edits can lead to duplicates in Module#ancestors
https://bugs.ruby-lang.org/issues/17038#change-86630

* Author: alanwu (Alan Wu)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-20T06:39:31Z master 935d0b3d05) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Running the following [script](https://wandbox.org/permlink/0f48S2QhvEO1cOBF) on master(935d0b3d05dfc8b30bba505792129bf0e33ebe3b),
`A` appears three times in the lookup chain of `C` and `A#foo` is called multiple
times with `super`.

```ruby
module A
  def foo
    [:a] + super
  end
end

module B
  def foo
    [:b] + super
  end
end

class Object
  def foo
    [:object]
  end
end

module C
  def foo
    [:c] + super
  end
end

class D
  prepend A
  include C
  include B


  def foo
    [:d] + super
  end
end

B.include A
C.include A

p D.ancestors
p D.new.foo
p RUBY_REVISION

__END__

[A, D, B, A, C, A, Object, Kernel, BasicObject]
[:a, :d, :b, :a, :c, :a, :object]
"935d0b3d05dfc8b30bba505792129bf0e33ebe3b"
```

This change was introduced in #9573. Is this behavior intentional?
In my opinion it's a bit odd since it's not possible to have duplicates
in the lookup chain on released versions. Allowing duplicates can
surprise peopole that are used to not having duplicates and lead to bugs.
If `A#foo` had side effects, for example, calling it multiple times
could be undesirable.

Also, logically it doesn't make sense to have a module be the ancestor of itself.
Comparison operators make less sense with this new setup.



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

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

* [ruby-core:99252] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors
  2020-07-20 23:04 [ruby-core:99242] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestor XrXr
                   ` (2 preceding siblings ...)
  2020-07-21  3:23 ` [ruby-core:99246] " XrXr
@ 2020-07-21 14:56 ` marcandre-ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: marcandre-ruby-core @ 2020-07-21 14:56 UTC (permalink / raw
  To: ruby-core

Issue #17038 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Open to Rejected

Note that this change is listed in the `NEWS`

I'm thus closing this.

----------------------------------------
Bug #17038: On master, ancestry edits can lead to duplicates in Module#ancestors
https://bugs.ruby-lang.org/issues/17038#change-86635

* Author: alanwu (Alan Wu)
* Status: Rejected
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-20T06:39:31Z master 935d0b3d05) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Running the following [script](https://wandbox.org/permlink/0f48S2QhvEO1cOBF) on master(935d0b3d05dfc8b30bba505792129bf0e33ebe3b),
`A` appears three times in the lookup chain of `C` and `A#foo` is called multiple
times with `super`.

```ruby
module A
  def foo
    [:a] + super
  end
end

module B
  def foo
    [:b] + super
  end
end

class Object
  def foo
    [:object]
  end
end

module C
  def foo
    [:c] + super
  end
end

class D
  prepend A
  include C
  include B


  def foo
    [:d] + super
  end
end

B.include A
C.include A

p D.ancestors
p D.new.foo
p RUBY_REVISION

__END__

[A, D, B, A, C, A, Object, Kernel, BasicObject]
[:a, :d, :b, :a, :c, :a, :object]
"935d0b3d05dfc8b30bba505792129bf0e33ebe3b"
```

This change was introduced in #9573. Is this behavior intentional?
In my opinion it's a bit odd since it's not possible to have duplicates
in the lookup chain on released versions. Allowing duplicates can
surprise peopole that are used to not having duplicates and lead to bugs.
If `A#foo` had side effects, for example, calling it multiple times
could be undesirable.

Also, logically it doesn't make sense to have a module be the ancestor of itself.
Comparison operators make less sense with this new setup.



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

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

end of thread, other threads:[~2020-07-21 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-20 23:04 [ruby-core:99242] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestor XrXr
2020-07-21  0:50 ` [ruby-core:99244] [Ruby master Bug#17038] On master, ancestry edits can lead to duplicates in Module#ancestors merch-redmine
2020-07-21  2:25 ` [ruby-core:99245] " marcandre-ruby-core
2020-07-21  3:23 ` [ruby-core:99246] " XrXr
2020-07-21 14:56 ` [ruby-core:99252] " marcandre-ruby-core

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).