ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "jeremyevans0 (Jeremy Evans) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "jeremyevans0 (Jeremy Evans)" <noreply@ruby-lang.org>
Subject: [ruby-core:116451] [Ruby master Bug#20213] zsuper with keyword splat without explicit keywords incorrectly uses mutable keyword splat
Date: Thu, 25 Jan 2024 21:50:00 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-20213.20240125214959.1604@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-20213.20240125214959.1604@ruby-lang.org

Issue #20213 has been reported by jeremyevans0 (Jeremy Evans).

----------------------------------------
Bug #20213: zsuper with keyword splat without explicit keywords incorrectly uses mutable keyword splat
https://bugs.ruby-lang.org/issues/20213

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
----------------------------------------
As the subject states, the super call in this code is compiled incorrectly:

```ruby
extend(Module.new{def a(**k) k[:a] = 1 end})
extend(Module.new{def a(**k) p k; super; p k end})
a

# Expected output, actual output on Ruby 2.0-3.2:
{}
{}

# Actual output on Ruby 3.3 and master
{}
{:a=>1}
```

The zsuper call here uses VM_CALL_KW_SPLAT_MUT:

```
invokesuper                            <calldata!argc:1, FCALL|SUPER|ZSUPER|KW_SPLAT|KW_SPLAT_MUT>, nil
```

That is not correct, because as the example shows, if the super method accepts a keyword splat, the super method can modify the keyword splat, and changes are reflected in the caller.

I submitted a pull request to fix this: https://github.com/ruby/ruby/pull/9710, and marked this for backporting to 3.3.



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

       reply	other threads:[~2024-01-25 21:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 21:50 jeremyevans0 (Jeremy Evans) via ruby-core [this message]
2024-01-26  4:54 ` [ruby-core:116455] [Ruby master Bug#20213] zsuper with keyword splat without explicit keywords incorrectly uses mutable keyword splat jeremyevans0 (Jeremy Evans) via ruby-core
2024-03-20 12:48 ` [ruby-core:117259] " naruse (Yui NARUSE) via ruby-core

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.issue-20213.20240125214959.1604@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    --cc=ruby-core@ml.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).