mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
ui: Improve reporting of missing closing parentheses.
Suggested by Ricardo Wurmus. Works around <https://bugs.gnu.org/28295>. * guix/ui.scm (report-load-error): Add case for 'read-error'. * tests/guix-system.sh: Test missing-closing-paren errors.
This commit is contained in:
parent
3f81ca324b
commit
a6e22d8445
2 changed files with 24 additions and 0 deletions
|
@ -257,6 +257,15 @@ (define* (report-load-error file args #:optional frame)
|
|||
(('system-error . rest)
|
||||
(let ((err (system-error-errno args)))
|
||||
(report-error (G_ "failed to load '~a': ~a~%") file (strerror err))))
|
||||
(('read-error "scm_i_lreadparen" message _ ...)
|
||||
;; Guile's missing-paren messages are obscure so we make them more
|
||||
;; intelligible here.
|
||||
(if (string-suffix? "end of file" message)
|
||||
(let ((location (string-drop-right message
|
||||
(string-length "end of file"))))
|
||||
(format (current-error-port) (G_ "~amissing closing parenthesis~%")
|
||||
location))
|
||||
(apply throw args)))
|
||||
(('syntax-error proc message properties form . rest)
|
||||
(let ((loc (source-properties->location properties)))
|
||||
(format (current-error-port) (G_ "~a: error: ~a~%")
|
||||
|
|
|
@ -53,6 +53,21 @@ else
|
|||
fi
|
||||
|
||||
|
||||
cat > "$tmpfile"<<EOF
|
||||
;; This is line 1, and the next one is line 2.
|
||||
(operating-system
|
||||
;; This is line 3, and there is no closing paren!
|
||||
EOF
|
||||
|
||||
if guix system vm "$tmpfile" 2> "$errorfile"
|
||||
then
|
||||
# This must not succeed.
|
||||
exit 1
|
||||
else
|
||||
grep "$tmpfile:4:1: missing closing paren" "$errorfile"
|
||||
fi
|
||||
|
||||
|
||||
# Reporting of unbound variables.
|
||||
|
||||
cat > "$tmpfile" <<EOF
|
||||
|
|
Loading…
Reference in a new issue