LibJS: Don't crash when attempting to load from an invalid reference

Previously, attempting to load a value from an invalid reference would
cause a crash. We now return a CodeGenerationError rather than hitting
an assertion. This is not a complete solution, as ideally we would want
to return a ReferenceError, but this now matches the behavior we see
when we attempt to store something to an invalid reference.
This commit is contained in:
Tim Ledbetter 2024-01-31 22:27:11 +00:00 committed by Andrew Kaster
commit 6c31f2a68a
Notes: sideshowbarker 2024-07-16 22:34:39 +09:00
2 changed files with 11 additions and 1 deletions

View file

@ -268,7 +268,10 @@ CodeGenerationErrorOr<Optional<Generator::ReferenceRegisters>> Generator::emit_l
}
return Optional<ReferenceRegisters> {};
}
VERIFY_NOT_REACHED();
return CodeGenerationError {
&node,
"Unimplemented/invalid node used a reference"sv
};
}
CodeGenerationErrorOr<void> Generator::emit_store_to_reference(JS::ASTNode const& node)