guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/04: ui: Improve reporting of missing closing parentheses.


From: Ludovic Courtès
Subject: 01/04: ui: Improve reporting of missing closing parentheses.
Date: Tue, 10 Oct 2017 17:12:18 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit a6e22d84450450cacc6fc36445f6ae378a5b7ad0
Author: Ludovic Courtès <address@hidden>
Date:   Tue Oct 10 10:22:43 2017 +0200

    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.
---
 guix/ui.scm          |  9 +++++++++
 tests/guix-system.sh | 15 +++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/guix/ui.scm b/guix/ui.scm
index 6dfc8c7..3c8734a 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -257,6 +257,15 @@ ARGS is the list of arguments received by the 'throw' 
handler."
     (('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~%")
diff --git a/tests/guix-system.sh b/tests/guix-system.sh
index d575795..31ee637 100644
--- a/tests/guix-system.sh
+++ b/tests/guix-system.sh
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]