picrin-scheme / picrin

lightweight scheme interpreter
MIT License
414 stars 35 forks source link

Better error reporting for uninitialized global. #313

Closed dcurrie closed 8 years ago

dcurrie commented 8 years ago

Reverse lookup in the hash table is inefficient, but useful for debugging, and only used in error reporting.

nyuichi commented 8 years ago

@dcurrie

Thanks for the p-r. Can you check the patch? I'll merge when the build gets fiexed.

dcurrie commented 8 years ago

I was surprised that the checks failed since it worked on OS X... clang compiler is usually thorough. But it appears I only tested PIC_NAN_BOXING or PIC_WORD_BOXING modes since these are automatically set on OS X x86_64. When pic_value is a struct pic_values cannot be compared with !=.

The only solution I can see is to extend khash with a val_equal parameter. I will sleep on it.

nyuichi commented 8 years ago

@dcurrie

Removing kh_reverse_get and iterating over khash using a for loop in the pic_reg_rev_ref function should work nice, I think? Outside khash.h you can forget about != and use pic_eq_p to compare pic_values.

dcurrie commented 8 years ago

@wasabiz Thanks for the suggestion... seems to pass all checks now.