Commit 4f61205b
4f61205bc61cMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified
Description
Merge pull request #370 from mame/pr/codegen-cruby-compat-string-index
fix(codegen): CRuby-compat for two String#index / #rindex sites
Details
- Commit
- 4f61205bc61c
- Parent
- 286d05bb0f02
- Merge parent
- 6b9e6f1988ba
spinel_codegen.rbmodifiedView file
@@ -1230,7 +1230,8 @@
12301230
end12311231
if @current_method_name != ""12321232
cls_idx = @current_method_name.index("_cls_")1233-
if cls_idx >= 01233+
# CRuby returns nil when not found; spinel runtime returns -1.1234+
if cls_idx != nil && cls_idx >= 012341235
return @current_method_name[0, cls_idx]12351236
end12361237
end@@ -7112,7 +7113,8 @@
71127113
mp = ""71137114
else71147115
idx = mp.rindex("_")7115-
if idx < 07116+
# CRuby returns nil when not found; spinel runtime returns -1.7117+
if idx == nil || idx < 071167118
mp = ""71177119
else71187120
mp = mp[0, idx]test/codegen_class_in_module_with_explicit_parent.rbaddedView file
Loading diff…
test/codegen_class_in_module_with_explicit_parent.rb.expectedaddedView file
Loading diff…
test/codegen_const_lookup_in_toplevel_method.rbaddedView file
Loading diff…
test/codegen_const_lookup_in_toplevel_method.rb.expectedaddedView file
Loading diff…