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) == 0
2339023390 return ""
2339123391 end
23392+ # Array#dig with a single index reduces to []. Multi-arg dig that
23393+ # walks into nested arrays/hashes isn't supported here yet — fall
23394+ # through to the unsupported-call warning.
23395+ if mname == "dig"
23396+ args_id = @nd_arguments[nid]
23397+ if args_id >= 0
23398+ aargs = get_args(args_id)
23399+ if aargs.length == 1
23400+ return compile_array_method_expr(nid, "[]", rc, recv_type)
23401+ end
23402+ end
23403+ end
2339223404 # arr.slice!(from, n) — returns a fresh array of `n` elements
2339323405 # starting at `from` and removes them from the receiver. Each
2339423406 # array type lowers to its own runtime helper that mutates the