Commit ceb7a9f5

ceb7a9f5b8baMerged

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

Description

codegen,analyze: Exception#backtrace returns empty str_array

spinel doesn't track per-exception frames (same model rationale as the deferred Kernel#caller in #878). Returning nil broke patterns like e.backtrace.first(2); return an empty str_array so .first / .length / .empty? work as expected. Documented limitation.

exception_object_methods test updated: backtrace == nil -> backtrace.empty?.

Refs #895

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

Details

Commit
ceb7a9f5b8ba
Parent
32b365630f94

spinel_analyze.rbmodifiedView file

@@ -2975,7 +2975,11 @@
29752975 return "string"
29762976 end
29772977 if mname == "backtrace"
2978- return "nil"
2978+ # Issue #895: spinel doesn't track per-exception frames;
2979+ # return an empty str_array (callers can call .first / .length
2980+ # safely). Documented limitation.
2981+ @needs_str_array = 1
2982+ return "str_array"
29792983 end
29802984 if mname == "is_a?" || mname == "kind_of?" || mname == "instance_of?"
29812985 return "bool"