ソースを参照

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 年 前
コミット
e93ee000e5
2 ファイル変更3 行追加3 行削除
  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'!