Shinmera / trivial-arguments

Tiny CL library to retrieve the arguments list of a function.
zlib License
22 stars 6 forks source link

sbcl - Incorrect arglist returned on low debug levels #7

Closed Zulu-Inuoe closed 1 year ago

Zulu-Inuoe commented 4 years ago

On SBCL 2.0.9:

(trivial-arguments:arglist (locally (declare (optimize (debug 0)))
                             (lambda (x y z) (+ x y z))))

returns nil, whereas upping debug:

(trivial-arguments:arglist (locally (declare (optimize (debug 3)))
                             (lambda (x y z) (+ x y z))))

gives me the expected result of (x y z)

I would instead expect :unknown, in order to detect that the lambda list couldn't be determined

phoe commented 4 years ago

I asked on #sbcl whether there is a way to tell whether the value returned by sb-introspect:function-lambda-list is NIL because the information was not saved from the situation where the lambda list is an empty list.

Shinmera commented 4 years ago

I don't believe SBCL gives us any way to distinguish the two.

phoe commented 4 years ago

Submitted upstream to https://bugs.launchpad.net/sbcl/+bug/1901781

snuglas commented 3 years ago

You may want to add your thoughts to https://groups.google.com/g/sbcl-devel/c/bCqU3TYyqxo/m/0YWwfkyoBQAJ which has attracted some criticism. I think I'll make sb-introspect return NIL for :UNKNOWN, but suggest to you that sb-kernel:%fun-lambda-list be used to detect the actual unknown case. The issue was internally we could not detect unknown, and now we can.

Zulu-Inuoe commented 3 years ago

@snuglas you may want to hold on that, as that change has been reverted partially and is still pending impl details.

Regardless you likely want to wait until the new SBCL version is officially out

stassats commented 3 years ago

I made it return two values, as using the internal sb-kernel:%fun-lambda-list is not a great idea.

Zulu-Inuoe commented 3 years ago

Oh oops. I misread what you suggested. I thought you'd be updating trivial-arguments to return nil rather than :unknown. Disregard