Opened 7 years ago

Closed 7 years ago

#1084 closed defect (fixed)

deficient error reporting in flet on bad lambda-list

Reported by: pjb@… Owned by: gb
Priority: normal Milestone:
Component: Compiler Version: 1.8
Keywords: flet labels lambda-list error detection Cc:


cl-user> (compile-file #P"~/test-flet.lisp")
cl-user> (cat  #P"~/test-flet.lisp")
(defun f (z)
  (flet ((g (x) (list x x))
         (u z))
    (g z)))

; No value

The fact that the "lambda-list" for u is an atom should signal a program-error.

CLHS flet says:

  lambda-list---a lambda list; for flet and labels, it is an ordinary lambda list; 

and CLHS 3.4.1 says:

The syntax for ordinary lambda lists is as follows:

lambda-list::= (var* 
                [&optional {var | (var [init-form [supplied-p-parameter]])}*] 
                [&rest var] 
                [&key {var | ({var | (keyword-name var)} [init-form [supplied-p-parameter]])}* [&allow-other-keys]] 
                [&aux {var | (var [init-form])}*]) 

so lambda-list for flet and labels cannot be an atom.

And in the case where I found this, u was also a global function, so perhaps this could be tested by the compiler to add a hint in the error message that perhaps the form was intented to be in the body of the flet.

Change History (2)

comment:1 Changed 7 years ago by gb

  • Owner set to gb
  • Status changed from new to assigned

After all these years of wondering what a "lambda list" was ... now I know!

Nothing calls or otherwise references the local function U in your example. There's no reason to compile that function, but there's no reason not to check that it has a valid lambda list (whatever that is ...) either.

comment:2 Changed 7 years ago by gb

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [15809]) METHOD-LAMBDA-P: don't choke on malformed lambda lists VERIFY-LAMBDA-LIST: explicit LISTP check, so that error message might

be clearer in some cases.

NX1-FLET: verify lambda list even if local function isn't referenced.

Be more explicit about error context if verification failed.

NX1-LABELS: Be more explicit about error context if verification failed.

Fixes ticket:1084 in the trunk.

Note: See TracTickets for help on using tickets.