lib: fix misleading argument of validateUint32 · nodejs/node@505e9a4 · GitHub
Skip to content

Commit 505e9a4

Browse files
tniessenRafaelGSS
authored andcommitted
lib: fix misleading argument of validateUint32
The type of the argument `positive` was declared as `boolean|number`, which is misleading because the function treats it as a boolean only. Some call sites even passed numbers, specifically, either `0` or `1`, which happen to work as expected because they are interpreted as `false` and `true`, respectively. However, passing `2` would silently lead to unexpected behavior. Thus, strictly make the argument a boolean. PR-URL: #53307 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent e7f3a3c commit 505e9a4

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/internal/test_runner/test.js

Lines changed: 2 additions & 2 deletions

lib/internal/validators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const validateInt32 = hideStackFrames(
129129
* @callback validateUint32
130130
* @param {*} value
131131
* @param {string} name
132-
* @param {number|boolean} [positive=false]
132+
* @param {boolean} [positive=false]
133133
* @returns {asserts value is number}
134134
*/
135135

lib/v8.js

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)