GNU bug report logs - #70187
[PATCH] Fix + ert for 'makunbound' and "local if set" notification bugs (6 of 9)

Previous Next

Package: emacs;

Reported by: Robert Burks <rburksdev <at> gmail.com>

Date: Thu, 4 Apr 2024 09:18:09 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 70187 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70187; Package emacs. (Thu, 04 Apr 2024 09:18:10 GMT) Full text and rfc822 format available.

Acknowledgement sent to Robert Burks <rburksdev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 04 Apr 2024 09:18:10 GMT) Full text and rfc822 format available.

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

From: Robert Burks <rburksdev <at> gmail.com>
To: GNU BUGS <bug-gnu-emacs <at> gnu.org>
Subject: [PATCH] Fix + ert for 'makunbound' and "local if set" notification
 bugs (6 of 9)
Date: Thu, 4 Apr 2024 04:46:26 -0400
[Message part 1 (text/plain, inline)]
(6 of 9)

Bug#00005 (Buffer local makunbounds lack 'where' in notification)
** Bug recreations are at the end

It wasn't until the last line of the test for the previous bug until I
realized
these existed. I have included a patch to fix this bug and the prior along
with
ert.  I have also included a patch that corrects an incorrect testing
assumption.
This is the only existing should form that I have found that was in error.
(This subject widely lacked testing previously.)

When a "local if set" variable or variable made local to a specific buffer
is
unbound in a buffer the notification should contain the location.

This bug could only be solved after the others as prior to my changes
notification was handled in aggregate at the top of set functions.
Handling these
bugs was dependent on notification being handled based on the redirect
path. This
could actually be applied after "bug#00001", I just worked on this last (It
took
a bit of gdb tracing to root out) and I didn't want to go back through and
renumber all my writing. (During proofreading way later I laughed because
there
ended up being far more after this.)

I have also included ert for previously untested error cases in
set_internal,
set_default_internal, and defvaralias.

Patch 0016: Fix for bugs 00004 and 00005 (four(4) places require bug#
update)

Patch 0017: Ert for bug#00004 (four(4) places require bug# update)

Patch 0018: Corrected one 'should' form to include buffer name

Patch 0019: Ert for bug#00005 (four(4) places require bug# update)

Patch 0020: Added ert for functions that lacked testing code coverage for
            basic input errors.

Bug
Recreation------------------------------------------------------------------

Watched variable becoming local in some buffer then being unbound.
---------------------------------------------------------------------------------------
(defvar test 5)
test

(defvar results nil)
results

(add-variable-watcher 'test (lambda (&rest args)
                              (push args results)))
nil

(with-temp-buffer
  (make-local-variable 'test)
  (set 'test 100)
  (makunbound 'test))
test
5

(set 'test 100)
100

results
((test 100 set nil) (test nil makunbound nil) (test 100 set #<killed
buffer>))
;; test is still bound in this buffer but 'where' is 'nil', it was unbound
in the temp buffer.
;; The final set shows nil as it should for a global.

(set 'results nil)
nil

(with-temp-buffer
  (make-local-variable 'test)
  (set 'test 100)
  (makunbound 'test)
  (set 'test 200))
200

test
100

(set 'test 300)

results
((test 300 set nil) (test 200 set #<killed buffer>) (test nil makunbound
nil) (test 100 set #<killed buffer>))
;; a watcher needs to know where this makunbound happened.

---------------------------------------------------------------------------------------
A "local if set" become unbound in some buffer,
---------------------------------------------------------------------------------------
(defvar-local test 5)
test

(defvar results nil)
results

(add-variable-watcher 'test (lambda (&rest args)
                              (push args results)))
nil

(with-temp-buffer
  (set 'test 100)
  (makunbound 'test))
test

(set 'test 100)
100

results
((test 100 set #<buffer *scratch*>) (test nil makunbound nil) (test 100 set
#<killed buffer>))

(set 'results nil)
nil

(with-temp-buffer
  (set 'test 100)
  (makunbound 'test)
  (set 'test 200))
200

test
100

(set 'test 300)
300

results
((test 300 set #<buffer *scratch*>) (test 200 set #<killed buffer>) (test
nil makunbound nil) (test 100 set #<killed buffer>))
[Message part 2 (text/html, inline)]
[0017-Added-ert-for-no-blv-watcher-unlet-notification-BUG-.patch (application/x-patch, attachment)]
[0019-Add-ert-for-missing-where-makunbound-watcher-bug-BUG.patch (application/x-patch, attachment)]
[0016-Fixes-for-two-variable-watcher-bugs-BUG-00004-BUG-00.patch (application/x-patch, attachment)]
[0020-Added-ert-for-previously-untested-for-error-cases.patch (application/x-patch, attachment)]
[0018-Fix-testing-assumptions-corrected-with-BUG-00005.patch (application/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70187; Package emacs. (Sat, 06 Apr 2024 07:40:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Burks <rburksdev <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 70187 <at> debbugs.gnu.org
Subject: Re: bug#70187: [PATCH] Fix + ert for 'makunbound' and "local if set"
 notification bugs (6 of 9)
Date: Sat, 06 Apr 2024 10:38:46 +0300
> From: Robert Burks <rburksdev <at> gmail.com>
> Date: Thu, 4 Apr 2024 04:46:26 -0400
> 
> (6 of 9)
> 
> Bug#00005 (Buffer local makunbounds lack 'where' in notification)
> ** Bug recreations are at the end           
> 
> It wasn't until the last line of the test for the previous bug until I realized
> these existed. I have included a patch to fix this bug and the prior along with
> ert.  I have also included a patch that corrects an incorrect testing assumption.
> This is the only existing should form that I have found that was in error.
> (This subject widely lacked testing previously.)
> 
> When a "local if set" variable or variable made local to a specific buffer is
> unbound in a buffer the notification should contain the location.
> 
> This bug could only be solved after the others as prior to my changes
> notification was handled in aggregate at the top of set functions.  Handling these
> bugs was dependent on notification being handled based on the redirect path. This
> could actually be applied after "bug#00001", I just worked on this last (It took
> a bit of gdb tracing to root out) and I didn't want to go back through and
> renumber all my writing. (During proofreading way later I laughed because there
> ended up being far more after this.)
> 
> I have also included ert for previously untested error cases in set_internal,
> set_default_internal, and defvaralias. 
> 
> Patch 0016: Fix for bugs 00004 and 00005 (four(4) places require bug# update)
> 
> Patch 0017: Ert for bug#00004 (four(4) places require bug# update)
> 
> Patch 0018: Corrected one 'should' form to include buffer name
> 
> Patch 0019: Ert for bug#00005 (four(4) places require bug# update)
> 
> Patch 0020: Added ert for functions that lacked testing code coverage for
>             basic input errors.
> 
> Bug Recreation------------------------------------------------------------------
> 
> Watched variable becoming local in some buffer then being unbound.
> ---------------------------------------------------------------------------------------
> (defvar test 5)
> test
> 
> (defvar results nil)
> results
> 
> (add-variable-watcher 'test (lambda (&rest args)
>                               (push args results)))
> nil
> 
> (with-temp-buffer
>   (make-local-variable 'test)
>   (set 'test 100)
>   (makunbound 'test))
> test
> 5
> 
> (set 'test 100)
> 100
> 
> results
> ((test 100 set nil) (test nil makunbound nil) (test 100 set #<killed buffer>))
> ;; test is still bound in this buffer but 'where' is 'nil', it was unbound in the temp buffer. 
> ;; The final set shows nil as it should for a global.
> 
> (set 'results nil)
> nil
> 
> (with-temp-buffer
>   (make-local-variable 'test)
>   (set 'test 100)
>   (makunbound 'test)
>   (set 'test 200))
> 200
> 
> test
> 100
> 
> (set 'test 300)
> 
> results
> ((test 300 set nil) (test 200 set #<killed buffer>) (test nil makunbound nil) (test 100 set #<killed buffer>))
> ;; a watcher needs to know where this makunbound happened.
> 
> ---------------------------------------------------------------------------------------
> A "local if set" become unbound in some buffer,
> ---------------------------------------------------------------------------------------
> (defvar-local test 5)
> test
> 
> (defvar results nil)
> results
> 
> (add-variable-watcher 'test (lambda (&rest args)
>                               (push args results)))
> nil
> 
> (with-temp-buffer
>   (set 'test 100)
>   (makunbound 'test))
> test
> 
> (set 'test 100)
> 100
> 
> results
> ((test 100 set #<buffer *scratch*>) (test nil makunbound nil) (test 100 set #<killed buffer>))
> 
> (set 'results nil)
> nil
> 
> (with-temp-buffer
>   (set 'test 100)
>   (makunbound 'test)
>   (set 'test 200))
> 200
> 
> test
> 100
> 
> (set 'test 300)
> 300
> 
> results
> ((test 300 set #<buffer *scratch*>) (test 200 set #<killed buffer>) (test nil makunbound nil) (test 100 set
> #<killed buffer>))

Stefan, any comments on the issues and the patches?  Note that the
patches were updated later in bug#70189.

Thanks.




This bug report was last modified 28 days ago.

Previous Next


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