mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
repl: Fix exception handling for interpreted code.
The 'stack' variable could be #f when code is interpreted, which in practice happens when running in "legacy" mode--i.e., when 'open-inferior' invokes "guile" instead of "guix repl". * guix/repl.scm (send-repl-response)[handle-exception]: Check whether STACK is true before passing it to 'stack->frames'. * tests/inferior.scm ("&inferior-exception, legacy mode"): New test.
This commit is contained in:
parent
074a201c33
commit
98d3abe744
2 changed files with 19 additions and 1 deletions
|
@ -78,8 +78,14 @@ (define reply
|
|||
(let ((stack (if (repl-prompt)
|
||||
(make-stack #t handle-exception (repl-prompt))
|
||||
(make-stack #t))))
|
||||
;; Note: 'make-stack' returns #f if there's no 'handle-exception'
|
||||
;; stack frame, which is the case when this file is being
|
||||
;; interpreted as with 'primitive-load'.
|
||||
`(exception (arguments ,key ,@(map value->sexp args))
|
||||
(stack ,@(map frame->sexp (stack->frames stack))))))
|
||||
(stack ,@(map frame->sexp
|
||||
(if stack
|
||||
(stack->frames stack)
|
||||
'()))))))
|
||||
(_
|
||||
;; Protocol (0 0).
|
||||
`(exception ,key ,@(map value->sexp args)))))
|
||||
|
|
|
@ -75,6 +75,18 @@ (define (manifest-entry->list entry)
|
|||
(inferior-eval '(throw 'a 'b 'c 'd) inferior)
|
||||
'badness)))
|
||||
|
||||
(test-equal "&inferior-exception, legacy mode"
|
||||
'(a b c d)
|
||||
;; Omit #:command to open an inferior in "legacy" mode, where Guile runs
|
||||
;; directly.
|
||||
(let ((inferior (open-inferior %top-builddir)))
|
||||
(guard (c ((inferior-exception? c)
|
||||
(close-inferior inferior)
|
||||
(and (eq? inferior (inferior-exception-inferior c))
|
||||
(inferior-exception-arguments c))))
|
||||
(inferior-eval '(throw 'a 'b 'c 'd) inferior)
|
||||
'badness)))
|
||||
|
||||
(test-equal "inferior-packages"
|
||||
(take (sort (fold-packages (lambda (package lst)
|
||||
(cons (list (package-name package)
|
||||
|
|
Loading…
Reference in a new issue