mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS: Fix reading cached source ranges
Made a slight logic error in 95d69fc
which meant the dummy range would
be returned even if the source_range_storage contained an actual source
range. This corrects that by resolving the null unrealized range to a
dummy range, and storing that. It then can be treated as a normal source
range.
This commit is contained in:
parent
95d69fcf74
commit
778265ae9d
Notes:
sideshowbarker
2024-07-17 06:29:49 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/778265ae9d Pull-request: https://github.com/SerenityOS/serenity/pull/19106
|
@ -17,12 +17,15 @@ namespace JS {
|
|||
|
||||
SourceRange const& TracebackFrame::source_range() const
|
||||
{
|
||||
if (auto* unrealized = source_range_storage.get_pointer<UnrealizedSourceRange>(); unrealized && unrealized->source_code) {
|
||||
auto source_range = unrealized->source_code->range_from_offsets(unrealized->start_offset, unrealized->end_offset);
|
||||
if (auto* unrealized = source_range_storage.get_pointer<UnrealizedSourceRange>()) {
|
||||
auto source_range = [&] {
|
||||
if (!unrealized->source_code) {
|
||||
static auto dummy_source_code = SourceCode::create(String {}, String {});
|
||||
return SourceRange { dummy_source_code, {}, {} };
|
||||
}
|
||||
return unrealized->source_code->range_from_offsets(unrealized->start_offset, unrealized->end_offset);
|
||||
}();
|
||||
source_range_storage = move(source_range);
|
||||
} else {
|
||||
static auto dummy_source_range = SourceRange { .code = SourceCode::create(String {}, String {}), .start = {}, .end = {} };
|
||||
return dummy_source_range;
|
||||
}
|
||||
return source_range_storage.get<SourceRange>();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue