unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28725: 26.0.60; Error when using Edebug on a generator
@ 2017-10-06 19:19 Gemini Lasswell
  2017-10-27 19:35 ` bug#28725: alternative Paul Pogonyshev
  2019-10-20 21:45 ` bug#28725: 26.0.60; Error when using Edebug on a generator Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Gemini Lasswell @ 2017-10-06 19:19 UTC (permalink / raw)
  To: 28725

Running a generator under Edebug results in an error message when it
gets to iter-yield.

To reproduce, put the code below into *scratch* and:

M-x edebug-all-defs RET
M-x eval-buffer RET
M-: (my-iter-do) RET
g

Result: Symbol’s function definition is void: cps-internal-yield


;;;  -*- lexical-binding: t -*-

(iter-defun mycounter (start)
  (let* ((i start))
    (while t
      (iter-yield i)
      (setq i (1+ i)))))

(defun my-iter-do ()
  (let (results
	(tally (mycounter 10)))
    (dotimes (_ 4)
      (push (iter-next tally) results))
    results))






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28725: alternative
  2017-10-06 19:19 bug#28725: 26.0.60; Error when using Edebug on a generator Gemini Lasswell
@ 2017-10-27 19:35 ` Paul Pogonyshev
  2017-10-28 21:18   ` Gemini Lasswell
  2019-10-20 21:45 ` bug#28725: 26.0.60; Error when using Edebug on a generator Lars Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Pogonyshev @ 2017-10-27 19:35 UTC (permalink / raw)
  To: 28725

You may want to try `iter2' package, which is a fully compatible
reimplementation of `generator'. Among other advantages, generator
functions it produces are compatible with Edebug. However, it's not
well-established, so be aware of possible misbehaving generators.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28725: alternative
  2017-10-27 19:35 ` bug#28725: alternative Paul Pogonyshev
@ 2017-10-28 21:18   ` Gemini Lasswell
  0 siblings, 0 replies; 5+ messages in thread
From: Gemini Lasswell @ 2017-10-28 21:18 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 28725

Paul Pogonyshev <pogonyshev@gmail.com> writes:

> You may want to try `iter2' package, which is a fully compatible
> reimplementation of `generator'. Among other advantages, generator
> functions it produces are compatible with Edebug.

Hi Paul,

Thanks for letting me know about iter2 and it's good to hear that it
works with Edebug. My interest in this bug is more about Edebug than
it is about generators, because I've been working on finding and
fixing code that ships with Emacs but doesn't work with Edebug.

Best,
Gemini






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28725: 26.0.60; Error when using Edebug on a generator
  2017-10-06 19:19 bug#28725: 26.0.60; Error when using Edebug on a generator Gemini Lasswell
  2017-10-27 19:35 ` bug#28725: alternative Paul Pogonyshev
@ 2019-10-20 21:45 ` Lars Ingebrigtsen
  2019-10-21 16:29   ` Gemini Lasswell
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-20 21:45 UTC (permalink / raw)
  To: Gemini Lasswell; +Cc: 28725

Gemini Lasswell <gazally@runbox.com> writes:

> Running a generator under Edebug results in an error message when it
> gets to iter-yield.
>
> To reproduce, put the code below into *scratch* and:
>
> M-x edebug-all-defs RET
> M-x eval-buffer RET
> M-: (my-iter-do) RET
> g
>
> Result: Symbol’s function definition is void: cps-internal-yield

I'm able to reproduce this bug in Emacs 27.

Does anybody know what's causing this?  It's bugging out in the
`iter-yield' call.

> ;;;  -*- lexical-binding: t -*-
>
> (iter-defun mycounter (start)
>   (let* ((i start))
>     (while t
>       (iter-yield i)
>       (setq i (1+ i)))))
>
> (defun my-iter-do ()
>   (let (results
> 	(tally (mycounter 10)))
>     (dotimes (_ 4)
>       (push (iter-next tally) results))
>     results))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28725: 26.0.60; Error when using Edebug on a generator
  2019-10-20 21:45 ` bug#28725: 26.0.60; Error when using Edebug on a generator Lars Ingebrigtsen
@ 2019-10-21 16:29   ` Gemini Lasswell
  0 siblings, 0 replies; 5+ messages in thread
From: Gemini Lasswell @ 2019-10-21 16:29 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 28725

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I'm able to reproduce this bug in Emacs 27.
>
> Does anybody know what's causing this?  It's bugging out in the
> `iter-yield' call.

I took a look and I think the problem is that cps--transform-1 doesn't
look inside lambda forms.  When Edebug instruments a function, it wraps
the body of the function in a lambda form.

Here's a code sample to reproduce the bug with just eval-buffer, no
Edebug necessary:

;;;  -*- lexical-binding: t -*-

(require 'generator)

(iter-defun mycounter (start)
  (let ((i 0)
	(offset-yield-func (lambda (x) (iter-yield (+ x start)))))
    (while t
      (funcall offset-yield-func i)
      (setq i (1+ i)))))

(defun my-iter-do ()
  (let (results
	(tally (mycounter 10)))
    (dotimes (_ 4)
      (push (iter-next tally) results))
    results))

(my-iter-do)






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-21 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-06 19:19 bug#28725: 26.0.60; Error when using Edebug on a generator Gemini Lasswell
2017-10-27 19:35 ` bug#28725: alternative Paul Pogonyshev
2017-10-28 21:18   ` Gemini Lasswell
2019-10-20 21:45 ` bug#28725: 26.0.60; Error when using Edebug on a generator Lars Ingebrigtsen
2019-10-21 16:29   ` Gemini Lasswell

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).