Export to GitHub

pure-lang - issue #82

Taking hash of an anon closure crashes


Posted on Jun 21, 2012 by Happy Bear

What steps will reproduce the problem? > hash (\x->x); Assertion failed: (x->tag>0), function hash, file runtime.cc, line 12294. Abort trap: 6 (core dumped)

What is the expected output? Expect not to crash.

Using Pure 0.53 on FreeBSD

Comment #1

Posted on Jun 21, 2012 by Happy Bear

Also, would like hash to be provided. Their hash can just be: hash (get_pointer (ref f)).

Comment #2

Posted on Jun 23, 2012 by Massive Panda

This issue was closed by revision d2a3ed9f36f2.

Comment #3

Posted on Jun 23, 2012 by Massive Panda

The assertion should be fixed. But I'm not sure if I understand your comment #1, can you elaborate? Note that the hash value of a closure is based on its key which uniquely identifies the underlying function. It's not based on the pointer to the closure object, if that's what you mean.

Comment #4

Posted on Jun 23, 2012 by Massive Panda

(No comment was entered for this change.)

Comment #5

Posted on Jun 24, 2012 by Happy Bear

It was just a suggestion about how the hash value could be derived. I understand your comment to mean that closures with the same underlying function but different environments nonetheless hash the same. (I presume they won't be ===.)

Comment #6

Posted on Jun 24, 2012 by Massive Panda

Ah yes, I see. It certainly makes sense to include the environment in the hash. (And yes, === works ok, it does compare the environments.)

Comment #7

Posted on Jun 24, 2012 by Massive Panda

This issue was closed by revision dce8bce7e7ea.

Status: Fixed

Labels:
Type-Defect Priority-Medium