Summary
Extended lambda list syntax with default values isn't checked properly
Metadata
- Id: 5186855173f892be71ca51625254b2e69dd74dbf
- Trac id: 575
- Type: defect
- Reporter: sjamaan
- Owner: felix
- Cc:
- Status: closed
- Component: expander
- Estimated difficulty:
- Resolution: fixed
- Priority: minor
- Milestone: 4.9.0
- Version: 4.6.x
- Changetime: 2012-09-24 21:47:48 UTC
- Created: 2011-05-17 12:00:47 UTC
- Keywords: DSSSL lambda list, keywords, optionals
Attachments
- 5186855173f892be71ca51625254b2e69dd74dbf/attachments/dsssl-check.patch
Description
When using a default value with an optional argument, you get a strange error message that there's an error in your LET syntax, and when you do the same with a keyword argument, Chicken segfaults.
The reason is there's a missing check in ##sys#expand-extended-lambda-list's final cond clause; it implicitly assumes that a 2-element list after #!key or #!optional always has a symbol as its car. The attached patch contains a simple fix and regression test.
CHICKEN
(c)2008-2010 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.6.0
netbsd-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2011-01-21 on langly (NetBSD)
#;1> (define (foo #!optional 0) 1)
Error: invalid lambda list syntax: (#!optional 0)
Call history:
<syntax> (define (foo #!optional 0) 1)
<syntax> (##core#set! foo (##core#lambda (#!optional 0) 1))
<syntax> (##core#lambda (#!optional 0) 1) <--
#;1> (define (foo #!optional (0 0)) 1)
Error: during expansion of (let12 ...) - in `let' - symbol expected: (let ((0 (optional tmp 0))) 1)
Call history:
<syntax> (define (foo #!optional (0 0)) 1)
<syntax> (##core#set! foo (##core#lambda (#!optional (0 0)) 1))
<syntax> (##core#lambda (#!optional (0 0)) 1) <--
#;1> (define (foo #!key 0) 1)
Error: invalid lambda list syntax: (#!key 0)
Call history:
<syntax> (define (foo #!key 0) 1)
<syntax> (##core#set! foo (##core#lambda (#!key 0) 1))
<syntax> (##core#lambda (#!key 0) 1) <--
#;1> (define (foo #!key (0 0)) 1)
zsh: segmentation fault csi
Changes and comments
[2011-05-17 12:01:04 UTC] sjamaan attached dsssl-check.patch (description=Add check for symbol-ness)
[2011-05-17 14:55:08 UTC] felix changed status from new to closed
[2011-05-17 14:55:08 UTC] felix set resolution to fixed
[2011-05-17 14:55:08 UTC] felix wrote:
Patch applied. Thanks.
[2012-09-24 21:47:48 UTC] felix changed milestone from 4.8.0 to 4.9.0
[2012-09-24 21:47:48 UTC] felix wrote:
Milestone 4.8.0 deleted