Skip to content

Commit

Permalink
Improve "key not found" error messages for string/symbol keys
Browse files Browse the repository at this point in the history
We don't know how to represent arbitrary objects as strings at this
low level, but this takes care of two very common cases.
  • Loading branch information
d-torrance committed Aug 17, 2024
1 parent 7ad574a commit 97412f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion M2/Macaulay2/d/hashtables.dd
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,12 @@ export lookup1force(object:HashTable,key:Expr,keyhash:hash_t):Expr := (
bucket = bucket.next;
);
if lockit then unlock(object.mutex);
buildErrorPacket("key not found in hash table"));
msg := "key not found in hash table";
when key
is x:stringCell do msg = msg + ": \"" + x.v + "\""
is x:SymbolClosure do msg = msg + ": " + x.symbol.word.name
else nothing;
buildErrorPacket(msg));
export lookup1force(object:HashTable,key:Expr):Expr := lookup1force(object,key,hash(key));
export lookup1Q(object:HashTable,key:Expr,keyhash:hash_t):bool := (
lockit := object.Mutable && !object.beingInitialized;
Expand Down

0 comments on commit 97412f0

Please sign in to comment.