summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-07-26 16:36:24 +0200
committerLudovic Courtès <ludo@gnu.org>2010-07-26 19:38:52 +0200
commit1af772303bf4eafb632a95bf4015a7736275e9e7 (patch)
tree06847e9a5d6da6bc3d020fc634144c0d8c346137
parentfefd60ba4ba751712c45c95362bbc2f858890678 (diff)
downloadguile-1af772303bf4eafb632a95bf4015a7736275e9e7.tar.gz
Import unbound variable reports in the VM.
* libguile/vm-engine.c (VM_NAME)[vm_error_unbound]: Add comment. * libguile/vm-i-system.c (variable_ref): Attempt provide the name of X in FINISH_ARGS.
-rw-r--r--libguile/vm-engine.c2
-rw-r--r--libguile/vm-i-system.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 7f4641a07..ff41ce4b6 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -140,6 +140,8 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
goto vm_error;
vm_error_unbound:
+ /* At this point FINISH_ARGS should be a one-element list containing
+ the name of the unbound variable. */
err_msg = scm_from_locale_string ("VM: Unbound variable: ~s");
goto vm_error;
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index 3af63082a..958f8b9c3 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -307,10 +307,13 @@ VM_DEFINE_INSTRUCTION (26, variable_ref, "variable-ref", 0, 1, 1)
{
SCM x = *sp;
- if (!VARIABLE_BOUNDP (x))
+ if (SCM_UNLIKELY (!VARIABLE_BOUNDP (x)))
{
- finish_args = scm_list_1 (x);
- /* Was: finish_args = SCM_LIST1 (SCM_CAR (x)); */
+ SCM var_name;
+
+ /* Attempt to provide the variable name in the error message. */
+ var_name = scm_module_reverse_lookup (scm_current_module (), x);
+ finish_args = scm_list_1 (scm_is_true (var_name) ? var_name : x);
goto vm_error_unbound;
}
else