diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-02-05 22:25:59 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-02-05 22:25:59 -0800 |
commit | 835542f9db8a98bcb105ca39d6d79d180fb0d011 (patch) | |
tree | 6fd4909ee0612c38194ef16fd9e9a8397b577008 /parser.y | |
parent | 71dba5fe6f84effd81b91e52b3fac8ac77fd7cf6 (diff) | |
download | txr-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.y | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -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; } |