Commit 1f71bb0d
1f71bb0d5e8eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified
Description
Merge pull request #1012 from neidiom/fix/hash-int-and-or-assign
fix: h[k] &&=/||= on int-valued hashes uses has_key, not _get return
Details
- Commit
- 1f71bb0d5e8e
- Parent
- a64533525e58
- Merge parent
- e3d9ebf8ae06
spinel_codegen.rbmodifiedView file
@@ -38344,7 +38344,7 @@
3834438344
tt = new_temp3834538345
ti = new_temp3834638346
emit(" { sp_" + pfx + " *" + tt + " = " + rc + "; mrb_int " + ti + " = " + idx_int_ia + ";")38347-
emit(" if (sp_" + pfx + "_get(" + tt + ", " + ti + ")) {")38347+
emit(" if (" + ti + " >= 0 && " + ti + " < " + tt + "->len) {")3834838348
val = compile_expr(@nd_expression[nid])3834938349
emit(" sp_" + pfx + "_set(" + tt + ", " + ti + ", (" + val + "));")3835038350
emit(" }")@@ -38356,7 +38356,7 @@
3835638356
ti = new_temp3835738357
idx_s = compile_expr_as_string(arg_ids[0])3835838358
emit(" { sp_StrIntHash *" + tt + " = " + rc + "; const char *" + ti + " = " + idx_s + ";")38359-
emit(" if (sp_StrIntHash_get(" + tt + ", " + ti + ")) {")38359+
emit(" if (sp_StrIntHash_has_key(" + tt + ", " + ti + ")) {")3836038360
val = compile_expr(@nd_expression[nid])3836138361
emit(" sp_StrIntHash_set(" + tt + ", " + ti + ", (" + val + "));")3836238362
emit(" }")@@ -38367,7 +38367,7 @@
3836738367
tt = new_temp3836838368
ti = new_temp3836938369
emit(" { sp_IntStrHash *" + tt + " = " + rc + "; mrb_int " + ti + " = " + idx + ";")38370-
emit(" if (sp_IntStrHash_get(" + tt + ", " + ti + ")) {")38370+
emit(" if (sp_IntStrHash_has_key(" + tt + ", " + ti + ")) {")3837138371
val = compile_expr(@nd_expression[nid])3837238372
emit(" sp_IntStrHash_set(" + tt + ", " + ti + ", (" + val + "));")3837338373
emit(" }")@@ -38378,7 +38378,7 @@
3837838378
tt = new_temp3837938379
ti = new_temp3838038380
emit(" { sp_SymIntHash *" + tt + " = " + rc + "; sp_sym " + ti + " = " + idx + ";")38381-
emit(" if (sp_SymIntHash_get(" + tt + ", " + ti + ")) {")38381+
emit(" if (sp_SymIntHash_has_key(" + tt + ", " + ti + ")) {")3838238382
val = compile_expr(@nd_expression[nid])3838338383
emit(" sp_SymIntHash_set(" + tt + ", " + ti + ", (" + val + "));")3838438384
emit(" }")@@ -38414,7 +38414,7 @@
3841438414
tt = new_temp3841538415
ti = new_temp3841638416
emit(" { sp_" + pfx + " *" + tt + " = " + rc + "; mrb_int " + ti + " = " + idx_int_or + ";")38417-
emit(" if (!sp_" + pfx + "_get(" + tt + ", " + ti + ")) {")38417+
emit(" if (" + ti + " < 0 || " + ti + " >= " + tt + "->len) {")3841838418
val = compile_expr(@nd_expression[nid])3841938419
emit(" sp_" + pfx + "_set(" + tt + ", " + ti + ", (" + val + "));")3842038420
emit(" }")@@ -38426,7 +38426,7 @@
3842638426
ti = new_temp3842738427
idx_s = compile_expr_as_string(arg_ids[0])3842838428
emit(" { sp_StrIntHash *" + tt + " = " + rc + "; const char *" + ti + " = " + idx_s + ";")38429-
emit(" if (!sp_StrIntHash_get(" + tt + ", " + ti + ")) {")38429+
emit(" if (!sp_StrIntHash_has_key(" + tt + ", " + ti + ")) {")3843038430
val = compile_expr(@nd_expression[nid])3843138431
emit(" sp_StrIntHash_set(" + tt + ", " + ti + ", (" + val + "));")3843238432
emit(" }")@@ -38437,7 +38437,7 @@
3843738437
tt = new_temp3843838438
ti = new_temp3843938439
emit(" { sp_IntStrHash *" + tt + " = " + rc + "; mrb_int " + ti + " = " + idx + ";")38440-
emit(" if (!sp_IntStrHash_get(" + tt + ", " + ti + ")) {")38440+
emit(" if (!sp_IntStrHash_has_key(" + tt + ", " + ti + ")) {")3844138441
val = compile_expr(@nd_expression[nid])3844238442
emit(" sp_IntStrHash_set(" + tt + ", " + ti + ", (" + val + "));")3844338443
emit(" }")@@ -38448,7 +38448,7 @@
3844838448
tt = new_temp3844938449
ti = new_temp3845038450
emit(" { sp_SymIntHash *" + tt + " = " + rc + "; sp_sym " + ti + " = " + idx + ";")38451-
emit(" if (!sp_SymIntHash_get(" + tt + ", " + ti + ")) {")38451+
emit(" if (!sp_SymIntHash_has_key(" + tt + ", " + ti + ")) {")3845238452
val = compile_expr(@nd_expression[nid])3845338453
emit(" sp_SymIntHash_set(" + tt + ", " + ti + ", (" + val + "));")3845438454
emit(" }")test/hash_int_and_or_assign.rbaddedView file
Loading diff…
test/hash_int_and_or_assign.rb.expectedaddedView file
Loading diff…