ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:100075] [Ruby master Bug#17007] SystemStackError when using super inside Module included and lexically inside refinement
Date: Tue, 22 Sep 2020 19:07:32 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-87628.20200922190731.772@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17007.20200703123257.772@ruby-lang.org

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

Status changed from Closed to Assigned

To restore compatibility with Ruby 2.7 and fix #17182, I've reverted commit:eeef16e190cdabc2ba474622720f8e3df7bac43b at commit:179384a66862d5ef7413b6f4850b97d0becf4ec9.

@shugo, I would appreciate your input here on how refinements should be handled in this case.

----------------------------------------
Bug #17007: SystemStackError when using super inside Module included and lexically inside refinement
https://bugs.ruby-lang.org/issues/17007#change-87628

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
```ruby
class C
  def foo
    ["C"]
  end
end

refinement = Module.new do
  R = refine C do
    def foo
      ["R"] + super
    end

    include Module.new {
      def foo
        ["M"] + super
      end
    }
  end
end

using refinement
p C.new.foo
```

gives

```
$ ruby bug_refine_super.rb
Traceback (most recent call last):
	10920: from bug_refine_super.rb:22:in `<main>'
	10919: from bug_refine_super.rb:10:in `foo'
	10918: from bug_refine_super.rb:15:in `foo'
	10917: from bug_refine_super.rb:10:in `foo'
	10916: from bug_refine_super.rb:15:in `foo'
	10915: from bug_refine_super.rb:10:in `foo'
	10914: from bug_refine_super.rb:15:in `foo'
	10913: from bug_refine_super.rb:10:in `foo'
	 ... 10908 levels...
	    4: from bug_refine_super.rb:15:in `foo'
	    3: from bug_refine_super.rb:10:in `foo'
	    2: from bug_refine_super.rb:15:in `foo'
	    1: from bug_refine_super.rb:10:in `foo'
bug_refine_super.rb:15:in `foo': stack level too deep (SystemStackError)
```

OTOH defining the module lexically outside of `refine` works:
```ruby
m = Module.new {
  def foo
    ["M"] + super
  end
}
refinement = Module.new do
  R = refine C do
    def foo
      ["R"] + super
    end

    include m
  end
end

# result: ["R", "M", "C"]
```



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

  parent reply	other threads:[~2020-09-22 19:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 12:32 [ruby-core:99044] [Ruby master Bug#17007] SystemStackError when using super inside Module included and lexically inside refinement eregontp
2020-07-10 22:20 ` [ruby-core:99119] " merch-redmine
2020-07-27 19:30 ` [ruby-core:99359] " eregontp
2020-07-27 21:02 ` [ruby-core:99362] " merch-redmine
2020-09-22 19:07 ` merch-redmine [this message]
2020-12-23  1:08 ` [ruby-core:101637] " shugo
2021-10-21 16:14 ` [ruby-core:105740] " jeremyevans0 (Jeremy Evans)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-87628.20200922190731.772@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).