GNU bug report logs -
#71503
30.0.50; pcase-lambda (with "and" and "guard") does not work as expected
Previous Next
Reported by: Mekeor Melire <mekeor <at> posteo.de>
Date: Wed, 12 Jun 2024 08:42:01 UTC
Severity: normal
Found in version 30.0.50
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
Message #49 received at 71503-done <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> Ping! can we please make progress with this issue, one way or
> another?
I've pushed the change in 0756f308 that Mekeor previously acknowledged
as fine. Closing.
>> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, mekeor <at> posteo.de, 71503 <at> debbugs.gnu.org
>> Date: Sun, 21 Jul 2024 09:51:04 -0400
>>
>> > Another confusing behaviour that we should document is that in
>> >
>> > (let ((a nil))
>> > (funcall
>> > (pcase-lambda (a (and (guard a) b))
>> > (list a b))
>> > 1 2))
>> >
>> > I would expect that the (guard a) would use the nil binding from the
>> > `let' form, but instead it is ignored and b is bound to 2. I am not
>> > sure if this is related to the "destructing" point or not.
>>
>> It most definitely is: the `guard` controls here whether the pattern
>> matches or not, but since it's a destructuring match `pcase` takes it
>> for granted that the pattern does match, so the guard is ignored.
>>
>> What might be more confusing is the scoping, e.g.:
>>
>> (macroexpand '(pcase-lambda ((and (guard a) b) a) (FOO)))
>> =>
>> #'(lambda (arg0 a) (pcase-let* (((and (guard a) b) arg0)) (FOO)))
>>
>> so the `a` in the guard refers to the argument that follows rather than
>> to a surrounding `a` binding.
>>
>>
>> Stefan
>>
>>
--
Philip Kaludercic on peregrine
This bug report was last modified 287 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.