Skip to content

Commit

Permalink
[patch] throw on negative set sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 18, 2023
1 parent c95890c commit a7c2506
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions aos/GetSetRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var GetIntrinsic = require('get-intrinsic');

var $RangeError = GetIntrinsic('%RangeError%');
var $TypeError = GetIntrinsic('%TypeError%');

var Get = require('es-abstract/2023/Get');
Expand Down Expand Up @@ -32,15 +33,19 @@ module.exports = function GetSetRecord(obj) {

var intSize = ToIntegerOrInfinity(numSize); // step 6

var has = Get(obj, 'has'); // step 7
if (intSize < 0) {
throw new $RangeError('set size must be non-negative'); // step 7
}

var has = Get(obj, 'has'); // step 8

if (!IsCallable(has)) {
throw new $TypeError('has is not a function'); // step 8
throw new $TypeError('has is not a function'); // step 9
}

var keys = Get(obj, 'keys'); // step 9
var keys = Get(obj, 'keys'); // step 10
if (!IsCallable(keys)) {
throw new $TypeError('keys is not a function'); // step 10
throw new $TypeError('keys is not a function'); // step 11
}
/* globals StopIteration: false */
if (isSet(obj) && typeof StopIteration === 'object') {
Expand All @@ -50,5 +55,5 @@ module.exports = function GetSetRecord(obj) {
};
}

return { '[[Set]]': obj, '[[Size]]': intSize, '[[Has]]': has, '[[Keys]]': keys }; // step 11
return { '[[Set]]': obj, '[[Size]]': intSize, '[[Has]]': has, '[[Keys]]': keys }; // step 12
};

0 comments on commit a7c2506

Please sign in to comment.