dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] iseq.c (iseq_data_to_ary): dump kw_arg as symbol
Date: Tue,  7 Jul 2015 19:37:59 +0000	[thread overview]
Message-ID: <1436297879-27154-1-git-send-email-e@80x24.org> (raw)

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

* iseq.c (iseq_data_to_ary): dump kw_arg as symbol
* test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip
---
 iseq.c                                 | 2 +-
 test/-ext-/iseq_load/test_iseq_load.rb | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/iseq.c b/iseq.c
index 48de119..1108f77 100644
--- a/iseq.c
+++ b/iseq.c
@@ -1820,7 +1820,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
 
 			orig_argc -= ci->kw_arg->keyword_len;
 			for (i = 0; i < ci->kw_arg->keyword_len; i++) {
-			    rb_ary_push(kw, ID2SYM(ci->kw_arg->keywords[i]));
+			    rb_ary_push(kw, ci->kw_arg->keywords[i]);
 			}
 			rb_hash_aset(e, ID2SYM(rb_intern("kw_arg")), kw);
 		    }
diff --git a/test/-ext-/iseq_load/test_iseq_load.rb b/test/-ext-/iseq_load/test_iseq_load.rb
index 7251603..5dfd69a 100644
--- a/test/-ext-/iseq_load/test_iseq_load.rb
+++ b/test/-ext-/iseq_load/test_iseq_load.rb
@@ -86,6 +86,15 @@ class TestIseqLoad < Test::Unit::TestCase
     assert_iseq_roundtrip(src)
   end
 
+  def test_kwarg
+    assert_iseq_roundtrip <<-'end;'
+      def foo(kwarg: :foo)
+        kwarg
+      end
+      foo(kwarg: :bar)
+    end;
+  end
+
   # FIXME: still failing
   def test_require_integration
     skip "iseq loader require integration tests still failing"
-- 
EW


                 reply	other threads:[~2015-07-07 19:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-all from there: mbox

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

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

  git send-email \
    --in-reply-to=1436297879-27154-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.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).