mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Can no longer use functions as dictionary keys
This commit is contained in:
@@ -380,7 +380,8 @@ int hashLiteral(Literal lit) {
|
||||
}
|
||||
|
||||
case LITERAL_FUNCTION:
|
||||
return 0;
|
||||
case LITERAL_FUNCTION_NATIVE:
|
||||
return 0; //TODO: find a way to hash these properly
|
||||
|
||||
case LITERAL_IDENTIFIER:
|
||||
return HASH_I(lit); //pre-computed
|
||||
|
||||
@@ -136,7 +136,13 @@ void freeLiteralDictionary(LiteralDictionary* dictionary) {
|
||||
|
||||
void setLiteralDictionary(LiteralDictionary* dictionary, Literal key, Literal value) {
|
||||
if (IS_NULL(key)) {
|
||||
fprintf(stderr, ERROR "[internal] Dictionaries can't have null keys (get)\n" RESET);
|
||||
fprintf(stderr, ERROR "Dictionaries can't have null keys (get)\n" RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
//BUGFIX: Can't hash a function
|
||||
if (IS_FUNCTION(key) || IS_FUNCTION_NATIVE(key)) {
|
||||
fprintf(stderr, ERROR "Dictionaries can't have function keys (get)\n" RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -150,7 +156,13 @@ void setLiteralDictionary(LiteralDictionary* dictionary, Literal key, Literal va
|
||||
|
||||
Literal getLiteralDictionary(LiteralDictionary* dictionary, Literal key) {
|
||||
if (IS_NULL(key)) {
|
||||
fprintf(stderr, ERROR "[internal] Dictionaries can't have null keys (set)\n" RESET);
|
||||
fprintf(stderr, ERROR "Dictionaries can't have null keys (set)\n" RESET);
|
||||
return TO_NULL_LITERAL;
|
||||
}
|
||||
|
||||
//BUGFIX: Can't hash a function
|
||||
if (IS_FUNCTION(key) || IS_FUNCTION_NATIVE(key)) {
|
||||
fprintf(stderr, ERROR "Dictionaries can't have function keys (set)\n" RESET);
|
||||
return TO_NULL_LITERAL;
|
||||
}
|
||||
|
||||
@@ -166,7 +178,13 @@ Literal getLiteralDictionary(LiteralDictionary* dictionary, Literal key) {
|
||||
|
||||
void removeLiteralDictionary(LiteralDictionary* dictionary, Literal key) {
|
||||
if (IS_NULL(key)) {
|
||||
fprintf(stderr, ERROR "[internal] Dictionaries can't have null keys (remove)\n" RESET);
|
||||
fprintf(stderr, ERROR "Dictionaries can't have null keys (remove)\n" RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
//BUGFIX: Can't hash a function
|
||||
if (IS_FUNCTION(key) || IS_FUNCTION_NATIVE(key)) {
|
||||
fprintf(stderr, ERROR "Dictionaries can't have function keys (remove)\n" RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user