refactor(value): align native type checks with quickjs-ng#748
Conversation
buke
commented
May 22, 2026
- switch promise, typed array, and array buffer detection to native quickjs-ng APIs
- add native collection, proxy, and immutable ArrayBuffer helpers with regression tests
- cover value.go changes with focused tests and coverage validation
- switch promise, typed array, and array buffer detection to native quickjs-ng APIs - add native collection, proxy, and immutable ArrayBuffer helpers with regression tests - cover value.go changes with focused tests and coverage validation
There was a problem hiding this comment.
Code Review
This pull request introduces support for Proxy objects, adds immutability controls for ArrayBuffers, and implements several new type predicates such as IsRegExp, IsMap, and IsProxy. It also refactors existing type checks and the ToUint8Array method to use native QuickJS functions for better efficiency. A critical bug was identified in the NewProxy implementation where target and handler references are consumed by the underlying C function without being incremented, which would lead to double-free errors during garbage collection.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #748 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 3726 3766 +40
=========================================
+ Hits 3726 3766 +40
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
- add detached Uint8Array coverage for the native JS_GetUint8Array failure path - add nil-context proxy coverage for the Context.NewProxy guard branch
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several new methods and predicates to the Context and Value types, including support for Proxies (NewProxy, ProxyTarget, ProxyHandler), immutable ArrayBuffers, and various JavaScript built-in types like Map, Set, and RegExp. It also refactors TypedArray detection and ToUint8Array to use native QuickJS functions. Feedback was provided to ensure ToUint8Array checks for a valid context to prevent panics, to correct the logic in typedArrayType regarding JS_TYPED_ARRAY_NONE, and to maintain consistency in boolean conversions.
- add detached ArrayBuffer coverage for the native ToByteArray failure branch - add detached TypedArray coverage for native conversion error branches
- replace fake typed-array error coverage with detached real buffer/view cases - cover marshal ArrayBuffer and TypedArray decode failure branches after native checks