Commit fce6225a

fce6225a1cf0Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified

Description

Implement callee, String#clone, NilClass#itself

Three small built-in method gaps from #1222:

  • callee resolves like method (the current method name).
  • String#clone behaves like dup for the value (scoped to string / mutable_str so it doesn't intercept array/hash clone).
  • NilClass#itself returns nil.

Refs #1222

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
fce6225a1cf0
Parent
24654f0664be

spinel_analyze.rbmodifiedView file

@@ -4286,7 +4286,7 @@
42864286 if mname == "itself" || mname == "then" || mname == "yield_self"
42874287 return 1
42884288 end
4289- if mname == "getbyte" || mname == "setbyte" || mname == "__method__" || mname == "__dir__"
4289+ if mname == "getbyte" || mname == "setbyte" || mname == "__method__" || mname == "__callee__" || mname == "__dir__"
42904290 return 1
42914291 end
42924292 if mname == "slice!" || mname == "intern"
@@ -4984,7 +4984,7 @@
49844984 if mname == "setbyte"
49854985 return "int"
49864986 end
4987- if mname == "__method__"
4987+ if mname == "__method__" || mname == "__callee__"
49884988 return "string"
49894989 end
49904990 # Issue #878: Kernel#__dir__ -- compile-time string.
@@ -5076,6 +5076,16 @@
50765076 end
50775077 return "string"
50785078 end
5079+ # String#clone behaves like dup for the value (spinel doesn't track
5080+ # the frozen-state copy distinction). Scoped to string/mutable_str so
5081+ # it doesn't intercept array/hash clone, which have their own paths.
5082+ # Issue #1222.
5083+ if mname == "clone" && recv >= 0
5084+ rt_cl = infer_type(recv)
5085+ if rt_cl == "string" || rt_cl == "mutable_str"
5086+ return rt_cl
5087+ end
5088+ end
50795089 if mname == "ord"
50805090 return "int"
50815091 end