Project

General

Profile

Actions

Bug #20213

closed

zsuper with keyword splat without explicit keywords incorrectly uses mutable keyword splat

Added by jeremyevans0 (Jeremy Evans) 3 months ago. Updated about 2 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:116451]

Description

As the subject states, the super call in this code is compiled incorrectly:

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.

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

  • Status changed from Open to Closed

Updated by naruse (Yui NARUSE) about 2 months ago

  • Backport changed from 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED to 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONE

ruby_3_3 69cee6fee50f63cd52d59325dc3780a6fc4e5ae2 merged revision(s) 771a2f039b9a059a73e8f111d1d46590fa697f63.

Actions

Also available in: Atom PDF

Like0
Like0Like0