Skip to content

Commit 2f7582c

Browse files
committed
chuck: keywords and strings are distinct map keys
1 parent 9206563 commit 2f7582c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

impls/chuck/types/subr/MalDissoc.ck

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ public class MalDissoc extends MalSubr
66
MalObject.slice(args, 1) @=> MalObject ks[];
77

88
MalObject result[0];
9-
int cachedKeys[0];
9+
string cachedKeys[0];
1010

1111
for( 0 => int i; i < ks.size(); i++ )
1212
{
13-
true => cachedKeys[ks[i].stringValue];
13+
ks[i].type => cachedKeys[ks[i].stringValue];
1414
}
1515

1616
for( 0 => int i; i < map.size(); 2 +=> i )
1717
{
1818
map[i] @=> MalObject key;
1919
map[i+1] @=> MalObject value;
2020

21-
if( !cachedKeys[key.stringValue] )
21+
if ( cachedKeys[key.stringValue] == null
22+
|| cachedKeys[key.stringValue] != key.type )
2223
{
2324
result << key;
2425
result << value;

impls/chuck/types/subr/MalGet.ck

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class MalGet extends MalSubr
2020
map[i] @=> mapKey;
2121
map[i+1] @=> mapValue;
2222

23-
if( keyName == mapKey.stringValue )
23+
if( keyName == mapKey.stringValue && args[1].type == mapKey.type )
2424
{
2525
true => isKeyPresent;
2626
}

impls/chuck/types/subr/MalIsContains.ck

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class MalIsContains extends MalSubr
1414
{
1515
map[i] @=> mapKey;
1616

17-
if( keyName == mapKey.stringValue )
17+
if( keyName == mapKey.stringValue && args[1].type == mapKey.type )
1818
{
1919
true => isKeyPresent;
2020
}

0 commit comments

Comments
 (0)