Commit 64130a15
64130a15db6fMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
Merge pull request #327 from ryanseys/fix/array-dig-single-arg
fix(codegen): Array#dig single-arg reduces to []
Details
- Commit
- 64130a15db6f
- Parent
- 54f72fe18953
- Merge parent
- ba28c1b57bfe
spinel_codegen.rbmodifiedView file
@@ -23389,6 +23389,18 @@
2338923389
if is_array_type(recv_type) == 02339023390
return ""2339123391
end23392+
# Array#dig with a single index reduces to []. Multi-arg dig that23393+
# walks into nested arrays/hashes isn't supported here yet — fall23394+
# through to the unsupported-call warning.23395+
if mname == "dig"23396+
args_id = @nd_arguments[nid]23397+
if args_id >= 023398+
aargs = get_args(args_id)23399+
if aargs.length == 123400+
return compile_array_method_expr(nid, "[]", rc, recv_type)23401+
end23402+
end23403+
end2339223404
# arr.slice!(from, n) — returns a fresh array of `n` elements2339323405
# starting at `from` and removes them from the receiver. Each2339423406
# array type lowers to its own runtime helper that mutates thetest/array_dig.rbaddedView file
Loading diff…
test/array_dig.rb.expectedaddedView file
Loading diff…