[plt-scheme] Possible bug in for/fold

From: Noel Welsh (noelwelsh at gmail.com)
Date: Fri Jun 27 11:20:02 EDT 2008


If for/fold has no accumulators but it does have for-clauses that
iterate one or more times it gets upset:

 -> (for/fold () ([i (in-range 4)]) (vector-set! (vector 0) 0 1))
context (lexical binding) expected 0 values, received 1 value: #<void>

This is because the body expression (in this case the vector-set!)
returns a value which for/fold is not expecting.  This is kinda
contrived, but has arisen in the context of a macro I'm writing that
expands into for/fold (not for/fold/derived yet -- one step at a

It could well be argued this is not a bug, but I suggest one of two

1. for/fold accepts the above case and returns vold

2. for/fold rejects this case and gives an error at macro expansion time


Posted on the users mailing list.