#224 closed defect (fixed)
map allows non-list arguments
| Reported by: | Jim Ursetto | Owned by: | felix winkelmann |
|---|---|---|---|
| Priority: | critical | Milestone: | |
| Component: | core libraries | Version: | 4.4.x |
| Keywords: | Cc: | ||
| Estimated difficulty: |
Description
If the first list argument to map is not actually a list, map will just return (). Version: git fd66e1b (master)
#;1> (map (lambda (x) x) 'foo)
()
#;2> (map 'foo 'foo)
()
Change History (7)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
As seen at http://paste.lisp.org/display/98612 the compiled output appears to be wrong, it appears to be an issue with internal-compiler-syntax on ##sys#map etc. where the argument is only tested for pair?. An error is not thrown for non-lists.
comment:3 Changed 16 years ago by
| Owner: | set to felix winkelmann |
|---|---|
| Status: | new → assigned |
Issue also affects for-each. Looks like a straightforward fix but I will let you handle it from here.
comment:4 Changed 16 years ago by
mario says galinha is using Chicken 4.2.0 to generate the snapshots, which explains why the snapshot bootstrap files are not affected; this problem was introduced in Chicken 4.2.1.
comment:5 Changed 16 years ago by
| Status: | assigned → accepted |
|---|---|
| Version: | → 4.4.x |
comment:6 Changed 16 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |
In 22699fd729e2b1e08e8bdb2d6a5d640382d209d8 (experimental), a check has been added (unless in unsafe mode). Note that this only checks for the arguments being lists, not "proper" lists - the loops terminate on the first non-pair argument found.

More data points: peter reports the same issue with 4.4.0, while mario (4.4.6) and moritz (4.4.6) find it works correctly.
I used
make spotlessand rebuilt the compiler with itself and it is still giving this issue. But it doesn't make sense; the code is clear that an error should occur.Originally this was on 4.4.6 macosx-unix-gnu-x86 but I have now reproduced it from a clean git clone on another platform, 4.4.6 linux-unix-gnu-x86.