diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-06-29 06:46:33 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-06-29 06:46:33 -0700 |
commit | 7006ede97348c57aff89d6af7d19bb6411d9b3f6 (patch) | |
tree | b99ec8faaf5b8db48c115aabf9d40c41cf304165 /match.c | |
parent | b39b7e8173e6f2c74b69ee0c5b4c448a154b5078 (diff) | |
download | txr-7006ede97348c57aff89d6af7d19bb6411d9b3f6.tar.gz txr-7006ede97348c57aff89d6af7d19bb6411d9b3f6.tar.bz2 txr-7006ede97348c57aff89d6af7d19bb6411d9b3f6.zip |
pattern lang: vertical-horizontal fallback regression.
Commit c9cab7138636c6c1d6e47f8d1a4053bec2dd0ad4, on Feb 1,
2019, breaks the following case:
@(define horiz)whatever@(end)
@(horiz)
The code assumes that if v_fun returned :decline, then the
function doesn't exist. That is false, because the function
may have a horizontal definition, as in the above example.
That's why in the original code, nothing was done in this case
to just allow the flow to proceed to the horizontal fallback,
where the call will be tried as a horizontal function.
The small problem with that was lack of a diagnosis when the
function actually doesn't exist (neither vertical nor
horizontal). In that case, the horizontal fallback will expect
a line of data. If no data arrives, then the undefined
function call is undiagnosed.
The idea behind c9cab7138636c6c1d6e47f8d1a4053bec2dd0ad4 was
to provide a diagnostic immediately. The right way to do that
is to check for a horizontal definition of the function. If
there isn't one, then error out, otherwise fall back on the
horizontal processing.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -4706,9 +4706,12 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; } else if (result == decline_k) { - /* Function declined; we know the lookup failed because - since rest(specline) is nil, this is not horizontal fallback. */ - sem_error(specline, lit("function ~s not found"), sym, nao); + /* Function declined, so we know there is no vertical function. + If the horizontal one doesn't exist also, let's error out + now instead of trying to get data for matching a horizontal + call that we known work out. */ + if (!cdr(uw_get_func(sym))) + sem_error(specline, lit("function ~s not found"), sym, nao); } else { return result; } |