summaryrefslogtreecommitdiffstats
path: root/parser.y
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-02-05 22:25:59 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-02-05 22:25:59 -0800
commit835542f9db8a98bcb105ca39d6d79d180fb0d011 (patch)
tree6fd4909ee0612c38194ef16fd9e9a8397b577008 /parser.y
parent71dba5fe6f84effd81b91e52b3fac8ac77fd7cf6 (diff)
downloadtxr-835542f9db8a98bcb105ca39d6d79d180fb0d011.tar.gz
txr-835542f9db8a98bcb105ca39d6d79d180fb0d011.tar.bz2
txr-835542f9db8a98bcb105ca39d6d79d180fb0d011.zip
bugfix: don't record source loc of symbols and numbers.
This prevents a bug which manifests itself as a totally bogus file name and line number being reported in a diagnostic. The cause is that source loc info is recorded for an interned symbol when it is first encountered in one place in the code. Then that symbol occurs again in another place (perhaps a different file) in such a way that its source loc info is inherited into a surrounding generated form which now has incorrect source loc info: the location of the first occurrence of the symbol not of this form. Then when some error is reported against the form, the bogus source loc info is shown. * parser.y (rlviable): New static function. (rlset): Only record source loc for forms which satisfy rlviable.
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y26
1 files changed, 22 insertions, 4 deletions
diff --git a/parser.y b/parser.y
index 52646afe..d5fd57f5 100644
--- a/parser.y
+++ b/parser.y
@@ -1617,12 +1617,30 @@ val expand_meta(val form, val menv)
}
}
+static val rlviable(val form)
+{
+ switch (type(form)) {
+ case NIL:
+ case LIT:
+ case CHR:
+ case NUM:
+ case SYM:
+ case BGNUM:
+ case FLNUM:
+ return nil;
+ default:
+ return t;
+ }
+}
+
val rlset(val form, val info)
{
- val cell = gethash_c(form_to_ln_hash, form, nulloc);
- loc place = cdr_l(cell);
- if (nilp(deref(place)))
- set(place, info);
+ if (rlviable(form)) {
+ val cell = gethash_c(form_to_ln_hash, form, nulloc);
+ loc place = cdr_l(cell);
+ if (nilp(deref(place)))
+ set(place, info);
+ }
return form;
}