diff --git a/source/literal.c b/source/literal.c index 06b80ac..76ffa5c 100644 --- a/source/literal.c +++ b/source/literal.c @@ -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 diff --git a/source/literal_dictionary.c b/source/literal_dictionary.c index 42b8455..ed708f4 100644 --- a/source/literal_dictionary.c +++ b/source/literal_dictionary.c @@ -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; }