#575 closed defect (fixed)
Extended lambda list syntax with default values isn't checked properly
Reported by: | sjamaan | Owned by: | felix winkelmann |
---|---|---|---|
Priority: | minor | Milestone: | 4.9.0 |
Component: | expander | Version: | 4.6.x |
Keywords: | DSSSL lambda list, keywords, optionals | Cc: | |
Estimated difficulty: |
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
Attachments (1)
Note: See
TracTickets for help on using
tickets.
Add check for symbol-ness