Summary

Extended lambda list syntax with default values isn't checked properly

Metadata

Attachments

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