Improve error messages for wrong/missing arguments
Suppose I write
\version "2.25.3"
\fixed { % <- missing pitch
c'4.-> d'8 f'4 g'4
}
LilyPond tells me:
/tmp/frescobaldi-zxwvvcm1/tmp9gllpjsg/document.ly:3:8: error: wrong type for argument 1. Expecting pitch, found (make-music (quote SequentialMusic) (quote elements) (list (make-music (quote NoteEvent) (quote articulations) (list (make-music (quote ArticulationEvent) (quote midi-extra-velocity) 20 (quote articulation-type) (quote accent))) (quote duration) (ly:make-duration 2 1) (quote pitch) (ly:make-pitch 0 0)) (make-music (quote NoteEvent) (quote duration) (ly:make-duration 3) (quote pitch) (ly:make-pitch 0 1)) (make-music (quote NoteEvent) (quote duration) (ly:make-duration 2) (quote pitch) (ly:make-pitch 0 3)) (make-music (quote NoteEvent) (quote duration) (ly:make-duration 2) (quote pitch) (ly:make-pitch 0 4))))
\fixed
{ % <- missing pitch
/tmp/frescobaldi-zxwvvcm1/tmp9gllpjsg/document.ly:5:2: error: syntax error, unexpected end of input, expecting \header
}
I understand perfectly well what LilyPond is telling me here. But a beginner? This is just gobbledygook.
It would be interesting to either change the write
representation of music objects so that they are printed with displayLilyMusic
(which will also affect Scheme code doing things like (pk music)
), or do it by hand in such messages.
We could also consider shortening the value with an ellipsis if it gets too long.
Another idea: determine what the type of the value actually is, probably through GOOPS, and print it. And another one: print the name of the function, if it was a simple \
lookup (not sure if that is easy to implement), and the name of the parameter (definitely feasible in most cases; \etc
is an exception).
Overall, my ideal error message would be
error: wrong type for argument 1 ('pitch') to \fixed: expecting pitch, found music: { c'4.-> d'8 f'4 g'4 }