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
end29772977
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 / .length2980+
# safely). Documented limitation.2981+
@needs_str_array = 12982+
return "str_array"29792983
end29802984
if mname == "is_a?" || mname == "kind_of?" || mname == "instance_of?"29812985
return "bool"spinel_codegen.rbmodifiedView file
Loading diff…
test/exception_backtrace_empty.rbaddedView file
Loading diff…
test/exception_backtrace_empty.rb.expectedaddedView file
Loading diff…
test/exception_object_methods.rbmodifiedView file
Loading diff…
test/exception_object_methods.rb.expectedmodifiedView file
Loading diff…