Skip to content
This repository was archived by the owner on Jul 18, 2020. It is now read-only.

Naive handling of infinite seq's in the &env #10

@weissjeffm

Description

@weissjeffm
(let [[a b] (iterate inc 1)] (serializable.fn/fn []))

Will try to consume the entire infinite seq even though nothing refers to it. This is because destructuring let will expand into a form that assigns the (iterate inc 1) sequence to a gensym. So it becomes part of &env and then serializable.fn tries to serialize it.

Obviously there is no way to completely avoid this, since infinite seq's are valid values. However in the example case, nothing even refers to it in the function itself.

I have a small assertion lib that also captures the env, and it handles this case correctly. It filters out any env entries that are not referred to in the asserted expression.

serializable.fn could do the same thing.

https://github.com/RedHatQE/test.assert/blob/master/src/test/assert.clj#L357-369

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions