You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LinkedMap.delete and LRUCache.delete return false for existing falsy values #1942
The exported LinkedMap.delete(key) returns false for an existing entry when its stored value is falsy, even though it removes the entry. LRUCache inherits the same behavior.
Reproduced on main at 6a2f42f72b8b1f2317d6f61c3f8f327ed980e0d9 (vscode-jsonrpc 10.0.0), using Node.js 22.22.3 on macOS arm64.
The same incorrect result occurs with false, '', null, undefined, and NaN. A truthy value returns true.
Expected behavior
Return whether the key existed and was removed, independently of its stored value. A missing key should still return false.
Cause and proposed fix
jsonrpc/src/common/linkedMap.ts implements deletion as return !!this.remove(key). Since remove returns the stored value, the boolean reflects value truthiness rather than key presence.
I have a small fix that checks key presence and retains the existing removal path, with regression coverage for both classes, falsy/truthy values, missing and repeated deletions, size, and iteration order. Both new tests fail on the original implementation; all 79 JSON-RPC Node tests pass with the fix. I plan to submit the corresponding PR.
This report and fix were prepared with Codex assistance.
Activity