Skip to content

refactor(engine): remove expect()-based panics from JsRegExp wrapper #4818

@Shivampal157

Description

@Shivampal157

While auditing the core engine's error handling, I found that the JsRegExp convenience wrapper relies on .expect() for internal invariants that are not strictly enforced by the type system. These can lead to host process crashes if a regression occurs in the engine.
Locations:
boa/core/engine/src/object/builtins/jsregexp.rs: Around L59–L68 (in JsRegExp::new).
boa/core/engine/src/object/builtins/jsregexp.rs: Boolean accessors (e.g., global, multiline) around L83–L108.
Proposed Fix:
Replace .expect() in JsRegExp::new with proper error propagation returning JsNativeError::internal().
Use ToBoolean semantics or explicit type checks instead of .as_boolean().expect() in accessors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions