1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Nonlocal prompt returns cause all effects

* module/language/cps/effects-analysis.scm (expression-effects): Prompts
  cause &all-effects.  I tried to limit this change to CSE but it was
  actually LICM that was borked, so better to be conservative
* test-suite/tests/control.test ("escape-only continuations"): Add
  test.
This commit is contained in:
Andy Wingo 2017-03-13 22:16:56 +01:00
parent c9910c6042
commit 0543ec96b2
2 changed files with 15 additions and 2 deletions

View file

@ -517,7 +517,10 @@ is or might be a read or a write to the same location as A."
((or ($ $fun) ($ $rec) ($ $closure))
(&allocate &unknown-memory-kinds))
(($ $prompt)
(&write-object &prompt))
;; Although the "main" path just writes &prompt, we don't know what
;; nonlocal predecessors of the handler do, so we conservatively
;; assume &all-effects.
&all-effects)
((or ($ $call) ($ $callk))
&all-effects)
(($ $branch k exp)

View file

@ -103,7 +103,17 @@
(cons element prefix)))
'()
lst)))))
(prefix 'a '(0 1 2 a 3 4 5)))))
(prefix 'a '(0 1 2 a 3 4 5))))
(pass-if "loop only in handler"
(let ((n #f))
(let lp ()
(or n
(call-with-prompt 'foo
(lambda ()
(set! n #t)
(abort-to-prompt 'foo))
(lambda (k) (lp))))))))
;;; And the case in which the compiler has to reify the continuation.
(with-test-prefix/c&e "reified continuations"