From: David Kastrup Date: Mon, 25 May 2015 12:08:34 +0000 (+0200) Subject: Issue 4421/2: Factor out music-function-call-error X-Git-Tag: release/2.19.22-1~63 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cae7c736c707a037457d13f8ac404807e769472e;p=lilypond.git Issue 4421/2: Factor out music-function-call-error --- diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index 5d45ea523c..fb52465ba5 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -42,6 +42,16 @@ (set! (ly:music-property m 'origin) location) m))) +(define (music-function-call-error parser loc fun m) + (let* ((sig (ly:music-function-signature fun)) + (pred (if (pair? (car sig)) (caar sig) (car sig)))) + (ly:parser-error parser + (format #f (_ "~a function cannot return ~a") + (type-name pred) + (value->lily-string m parser)) + loc) + (and (pair? (car sig)) (cdar sig)))) + ;; Music function: Apply function and check return value. ;; args are in reverse order, rest may specify additional ones ;; @@ -61,14 +71,9 @@ (if (ly:music? m) (set! (ly:music-property m 'origin) loc)) m) - (begin - (if good - (ly:parser-error parser - (format #f (_ "~a function cannot return ~a") - (type-name pred) - (value->lily-string m parser)) - loc)) - (and (pair? (car sig)) (cdar sig)))))) + (if good + (music-function-call-error parser loc fun m) + (and (pair? (car sig)) (cdar sig)))))) (define-ly-syntax (argument-error parser location n pred arg) (ly:parser-error