GNU bug report logs - #68232
[PATCH] Fix range-intersection implementation

Previous Next

Package: emacs;

Reported by: Zachary Romero <zacromero <at> posteo.net>

Date: Wed, 3 Jan 2024 17:39:03 UTC

Severity: normal

Tags: patch, pending

Full log


Message #11 received at 68232 <at> debbugs.gnu.org (full text, mbox):

From: zacromero <at> posteo.net
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 68232 <at> debbugs.gnu.org, Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#68232: [PATCH] Fix range-intersection implementation
Date: Fri, 12 Jan 2024 02:44:29 +0000
[Message part 1 (text/plain, inline)]
Thanks for pointing me to the tests. Attached is an updated patch with 
the added test cases and the range tests all pass.

On 11.01.2024 21:56, Stefan Kangas wrote:
> Zachary Romero <zacromero <at> posteo.net> writes:
> 
>> Hello Emacs maintainers,
>> 
>> I was using the range package when I encountered a bug in the
>> implementation of range-intersection.  The bug seems to occur when the
>> ranges involve a mix of integers and cons pairs.  The following are 
>> some
>> cases where the current implementation fails to compute the correct
>> intersection:
>> 
>> (range-intersection '((1 . 10) 11) '((11 . 12)))
>> ;; Expects (11), returns nil
>> 
>> (range-intersection '(11 (13 . 15)) '((13 . 15)))
>> ;; Expects (13 . 15), returns nil
>> 
>> (range-intersection '(1 11 13 15) '((1 . 2) (10 . 20)))
>> ;; Expects (1 11 13 15), returns (1)
>> 
>> 
>> I also refactored this function using pcase to try to make the steps 
>> of
>> the algorithm more understandable.
>> 
>> Let me know you thoughts and if there's any further changes I should
>> make.
> 
> Thanks for the patch.  Could you please add tests for this as well?
> See the file range-tests.el.
> 
> Did you check that the existing tests all still pass?
[0001-fix-range-intersection-edge-cases.patch (application/octet-stream, attachment)]

This bug report was last modified 180 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.