summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-29 06:46:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-29 06:46:33 -0700
commit8f1acc0fd61b9b52e22a5dfb9e0dc267f763b379 (patch)
treeb99ec8faaf5b8db48c115aabf9d40c41cf304165
parent50de9a02f779fbc96277a5cdd96c1e66d2e02ba0 (diff)
downloadtxr-8f1acc0fd61b9b52e22a5dfb9e0dc267f763b379.tar.gz
txr-8f1acc0fd61b9b52e22a5dfb9e0dc267f763b379.tar.bz2
txr-8f1acc0fd61b9b52e22a5dfb9e0dc267f763b379.zip
pattern lang: vertical-horizontal fallback regression.
Commit aa50bc474d9044dcf2ead5676314bdd9f59421ac, 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 aa50bc474d9044dcf2ead5676314bdd9f59421ac 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.
-rw-r--r--match.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/match.c b/match.c
index 3bb1f719..710a56ef 100644
--- a/match.c
+++ b/match.c
@@ -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;
}