From 6b949a190c4756d24adabd32a60d1e235490acb1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 6 Dec 2007 21:49:17 +0000 Subject: [PATCH] improve error message on re-definition of a constant svn: r7907 --- src/mzscheme/src/syntax.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mzscheme/src/syntax.c b/src/mzscheme/src/syntax.c index a83f069418..749b8ac906 100644 --- a/src/mzscheme/src/syntax.c +++ b/src/mzscheme/src/syntax.c @@ -617,17 +617,22 @@ void scheme_set_global_bucket(char *who, Scheme_Bucket *b, Scheme_Object *val, else { if (((Scheme_Bucket_With_Home *)b)->home->module) { const char *msg; + int is_set; if (SCHEME_TRUEP(scheme_get_param(scheme_current_config(), MZCONFIG_ERROR_PRINT_SRCLOC))) msg = "%s: cannot %s: %S in module: %D"; else msg = "%s: cannot %s: %S"; + is_set = !strcmp(who, "set!"); + scheme_raise_exn(MZEXN_FAIL_CONTRACT_VARIABLE, b->key, msg, who, (b->val - ? "change identifier that is instantiated as a module constant" + ? (is_set + ? "modify a constant" + : "re-define a constant") : "set identifier before its definition"), (Scheme_Object *)b->key, ((Scheme_Bucket_With_Home *)b)->home->module->modname);