Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print missing key in error message #1530

Closed
mahrud opened this issue Oct 3, 2020 · 1 comment · Fixed by #3409
Closed

print missing key in error message #1530

mahrud opened this issue Oct 3, 2020 · 1 comment · Fixed by #3409

Comments

@mahrud
Copy link
Member

mahrud commented Oct 3, 2020

I often run into mysterious error messages like this:

stdio:11:59:(3): error: key not found in hash table

In this instance, I was trying to figure out the issue mentioned in this comment, and this error is utterly unhelpful.

@DanGrayson I figure the best solution is to perhaps print the key in the error message, which happens here:

export lookup1force(object:HashTable,key:Expr,keyhash:int):Expr := (
keymod := int(keyhash & (length(object.table)-1));
bucket := object.table.keymod;
while bucket != bucket.next do (
if bucket.key == key || bucket.hash == keyhash && equal(bucket.key,key)==True then return bucket.value;
bucket = bucket.next;
);
buildErrorPacket("key not found in hash table"));

One wrinkle is that the key can be any Expr object, and probably turning it into a string is not always the best idea. Could we print it if it's an integer or string perhaps? Do you have any better ideas?

@DanGrayson
Copy link
Member

In robust.m2 are silentRobustNetWithClass and silentRobustNet, which print things while limiting the size. They are used in error messages like this one:

i4 : (300:1) + (300:2)
stdio:4:9:(3): error: no method for binary operator + applied to objects:
--            (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1. (of class Sequence)
--      +     (2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2. (of class Sequence)

(I wish there were 3 dots instead of just one at the cutoff points.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants