1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c: hash must be paired

* compile.c (compile_array_): hash elements must be paired even for
  literal elements.  [ruby-dev:46658] [Bug #7466]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-11-29 10:15:16 +00:00
parent f77c97a8ca
commit 399a32dfca
3 changed files with 146 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Nov 29 19:15:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (compile_array_): hash elements must be paired even for
literal elements. [ruby-dev:46658] [Bug #7466]
Thu Nov 29 17:45:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Nov 29 17:45:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* variable.c (rb_const_set): show namespace in warning messages. * variable.c (rb_const_set): show namespace in warning messages.

View file

@ -2379,11 +2379,15 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
rb_ary_push(ary, node->nd_head->nd_lit); rb_ary_push(ary, node->nd_head->nd_lit);
node = node->nd_next; node = node->nd_next;
} }
while (node && nd_type(node->nd_head) == NODE_LIT) { while (node && nd_type(node->nd_head) == NODE_LIT &&
node->nd_next && nd_type(node->nd_next->nd_head) == NODE_LIT) {
rb_ary_push(ary, node->nd_head->nd_lit);
node = node->nd_next;
rb_ary_push(ary, node->nd_head->nd_lit); rb_ary_push(ary, node->nd_head->nd_lit);
node = node->nd_next; node = node->nd_next;
len++; len++;
} }
assert(RARRAY_LEN(ary) % 2 == 0);
OBJ_FREEZE(ary); OBJ_FREEZE(ary);

View file

@ -1,3 +1,4 @@
# -*- coding: us-ascii -*-
require 'test/unit' require 'test/unit'
require_relative 'envutil' require_relative 'envutil'
@ -192,6 +193,141 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("[#{(1..1_000_000).to_a.join(", ")}]").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems] assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("[#{(1..1_000_000).to_a.join(", ")}]").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems]
assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("{#{(1..1_000_000).map{|n| "#{n} => x"}.join(', ')}}").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems] assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("{#{(1..1_000_000).map{|n| "#{n} => x"}.join(', ')}}").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems]
assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("{#{(1..1_000_000).map{|n| "#{n} => #{n}"}.join(', ')}}").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems] assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("{#{(1..1_000_000).map{|n| "#{n} => #{n}"}.join(', ')}}").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems]
bug7466 = '[ruby-dev:46658]'
h = {
0xFE042 => 0xE5CD,
0xFE043 => 0xE5CD,
0xFE045 => 0xEA94,
0xFE046 => 0xE4E3,
0xFE047 => 0xE4E2,
0xFE048 => 0xEA96,
0xFE049 => 0x3013,
0xFE04A => 0xEB36,
0xFE04B => 0xEB37,
0xFE04C => 0xEB38,
0xFE04D => 0xEB49,
0xFE04E => 0xEB82,
0xFE04F => 0xE4D2,
0xFE050 => 0xEB35,
0xFE051 => 0xEAB9,
0xFE052 => 0xEABA,
0xFE053 => 0xE4D4,
0xFE054 => 0xE4CD,
0xFE055 => 0xEABB,
0xFE056 => 0xEABC,
0xFE057 => 0xEB32,
0xFE058 => 0xEB33,
0xFE059 => 0xEB34,
0xFE05A => 0xEB39,
0xFE05B => 0xEB5A,
0xFE190 => 0xE5A4,
0xFE191 => 0xE5A5,
0xFE192 => 0xEAD0,
0xFE193 => 0xEAD1,
0xFE194 => 0xEB47,
0xFE195 => 0xE509,
0xFE196 => 0xEAA0,
0xFE197 => 0xE50B,
0xFE198 => 0xEAA1,
0xFE199 => 0xEAA2,
0xFE19A => 0x3013,
0xFE19B => 0xE4FC,
0xFE19C => 0xE4FA,
0xFE19D => 0xE4FC,
0xFE19E => 0xE4FA,
0xFE19F => 0xE501,
0xFE1A0 => 0x3013,
0xFE1A1 => 0xE5DD,
0xFE1A2 => 0xEADB,
0xFE1A3 => 0xEAE9,
0xFE1A4 => 0xEB13,
0xFE1A5 => 0xEB14,
0xFE1A6 => 0xEB15,
0xFE1A7 => 0xEB16,
0xFE1A8 => 0xEB17,
0xFE1A9 => 0xEB18,
0xFE1AA => 0xEB19,
0xFE1AB => 0xEB1A,
0xFE1AC => 0xEB44,
0xFE1AD => 0xEB45,
0xFE1AE => 0xE4CB,
0xFE1AF => 0xE5BF,
0xFE1B0 => 0xE50E,
0xFE1B1 => 0xE4EC,
0xFE1B2 => 0xE4EF,
0xFE1B3 => 0xE4F8,
0xFE1B4 => 0x3013,
0xFE1B5 => 0x3013,
0xFE1B6 => 0xEB1C,
0xFE1B9 => 0xEB7E,
0xFE1D3 => 0xEB22,
0xFE7DC => 0xE4D8,
0xFE1D4 => 0xEB23,
0xFE1D5 => 0xEB24,
0xFE1D6 => 0xEB25,
0xFE1CC => 0xEB1F,
0xFE1CD => 0xEB20,
0xFE1CE => 0xE4D9,
0xFE1CF => 0xE48F,
0xFE1C5 => 0xE5C7,
0xFE1C6 => 0xEAEC,
0xFE1CB => 0xEB1E,
0xFE1DA => 0xE4DD,
0xFE1E1 => 0xEB57,
0xFE1E2 => 0xEB58,
0xFE1E3 => 0xE492,
0xFE1C9 => 0xEB1D,
0xFE1D9 => 0xE4D3,
0xFE1DC => 0xE5D4,
0xFE1BA => 0xE4E0,
0xFE1BB => 0xEB76,
0xFE1C8 => 0xE4E0,
0xFE1DD => 0xE5DB,
0xFE1BC => 0xE4DC,
0xFE1D8 => 0xE4DF,
0xFE1BD => 0xE49A,
0xFE1C7 => 0xEB1B,
0xFE1C2 => 0xE5C2,
0xFE1C0 => 0xE5C0,
0xFE1B8 => 0xE4DB,
0xFE1C3 => 0xE470,
0xFE1BE => 0xE4D8,
0xFE1C4 => 0xE4D9,
0xFE1B7 => 0xE4E1,
0xFE1BF => 0xE4DE,
0xFE1C1 => 0xE5C1,
0xFE1CA => 0x3013,
0xFE1D0 => 0xE4E1,
0xFE1D1 => 0xEB21,
0xFE1D2 => 0xE4D7,
0xFE1D7 => 0xE4DA,
0xFE1DB => 0xE4EE,
0xFE1DE => 0xEB3F,
0xFE1DF => 0xEB46,
0xFE1E0 => 0xEB48,
0xFE336 => 0xE4FB,
0xFE320 => 0xE472,
0xFE321 => 0xEB67,
0xFE322 => 0xEACA,
0xFE323 => 0xEAC0,
0xFE324 => 0xE5AE,
0xFE325 => 0xEACB,
0xFE326 => 0xEAC9,
0xFE327 => 0xE5C4,
0xFE328 => 0xEAC1,
0xFE329 => 0xE4E7,
0xFE32A => 0xE4E7,
0xFE32B => 0xEACD,
0xFE32C => 0xEACF,
0xFE32D => 0xEACE,
0xFE32E => 0xEAC7,
0xFE32F => 0xEAC8,
0xFE330 => 0xE471,
0xFE331 => "[Bug #7466]",
}
k = h.keys
assert_equal([129, 0xFE331], [k.size, k.last], bug7466)
end end
def test_range def test_range