Browse Source

Fix #1224: Set removal of primitive values.

`(Set new remove: nil ifAbsent: []; yourself) size` was -1.
Same for booleans, numbers, strings.
JS `delete foo.bar` returned false positives.
Switched to `bar in foo` testing.
Herbert Vojčík 7 years ago
parent
commit
e93ee000e5
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/Kernel-Collections.js
  2. 1 1
      src/Kernel-Collections.st

+ 2 - 2
src/Kernel-Collections.js

@@ -8583,7 +8583,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-if (delete anotherObject.store[anObject]) $self['@size']--;
+if (anObject in anotherObject.store) { delete anotherObject.store[anObject]; $self['@size']--; };
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"remove:in:",{anObject:anObject,anotherObject:anotherObject},$globals.Set)});
@@ -8591,7 +8591,7 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anObject", "anotherObject"],
-source: "remove: anObject in: anotherObject\x0a\x09<inlineJS: 'if (delete anotherObject.store[anObject]) $self[''@size'']--'>",
+source: "remove: anObject in: anotherObject\x0a\x09<inlineJS: 'if (anObject in anotherObject.store) { delete anotherObject.store[anObject]; $self[''@size'']--; }'>",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []

+ 1 - 1
src/Kernel-Collections.st

@@ -2086,7 +2086,7 @@ jsConstructorNameOf: anObject
 !
 
 remove: anObject in: anotherObject
-	<inlineJS: 'if (delete anotherObject.store[anObject]) $self[''@size'']--'>
+	<inlineJS: 'if (anObject in anotherObject.store) { delete anotherObject.store[anObject]; $self[''@size'']--; }'>
 ! !
 
 !Set methodsFor: 'testing'!