From 462cef0beb326dea3878456fda920592bab3d126 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Fri, 12 Jul 2013 15:03:08 +0200 Subject: [PATCH] Issue 3444: No warning for misspelled properties This makes sure that properties are checked to be assignable even when assigning #f or '() to them. --- lily/context.cc | 4 ++-- lily/lily-guile.cc | 52 ++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lily/context.cc b/lily/context.cc index 3453284cd8..583b2eac89 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -256,8 +256,8 @@ Context::set_property_from_event (SCM sev) } bool ok = true; - if (val != SCM_EOL) - ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")); + ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")); + if (ok) set_property (sym, val); } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 27909a6bc2..5e3b1c0f69 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -399,16 +399,6 @@ print_scm_val (SCM val) bool type_check_assignment (SCM sym, SCM val, SCM type_symbol) { - bool ok = true; - - /* - Always succeeds. - - - TODO: should remove #f from allowed vals? - */ - if (val == SCM_EOL || val == SCM_BOOL_F) - return ok; // If undefined, some internal function caused it...should never happen. assert (val != SCM_UNDEFINED); @@ -429,26 +419,34 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_3 (ly_symbol2scm ("typecheck"), sym, val)); - warning (_ ("doing assignment anyway")); + warning (_ ("skipping assignment")); + return false; } - else + + /* + Always succeeds. + + + TODO: should remove #f from allowed vals? + */ + if (val == SCM_EOL || val == SCM_BOOL_F) + return true; + + if (val != SCM_EOL + && ly_is_procedure (type) + && scm_call_1 (type, val) == SCM_BOOL_F) { - if (val != SCM_EOL - && ly_is_procedure (type) - && scm_call_1 (type, val) == SCM_BOOL_F) - { - ok = false; - SCM typefunc = ly_lily_module_constant ("type-name"); - SCM type_name = scm_call_1 (typefunc, type); - - warning (_f ("type check for `%s' failed; value `%s' must be of type `%s'", - ly_symbol2string (sym).c_str (), - print_scm_val (val), - ly_scm2string (type_name).c_str ())); - progress_indication ("\n"); - } + SCM typefunc = ly_lily_module_constant ("type-name"); + SCM type_name = scm_call_1 (typefunc, type); + + warning (_f ("type check for `%s' failed; value `%s' must be of type `%s'", + ly_symbol2string (sym).c_str (), + print_scm_val (val), + ly_scm2string (type_name).c_str ())); + progress_indication ("\n"); + return false; } - return ok; + return true; } /* some SCM abbrevs -- 2.39.5