[master] 67ea0c83c Distinguish $TYPE.property from $TYPE.method() by insisting in ()
Poul-Henning Kamp
phk at FreeBSD.org
Wed Aug 14 08:27:06 UTC 2019
commit 67ea0c83c3eb7df9e971fa8011cc0cbe2814ca57
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Aug 14 08:25:50 2019 +0000
Distinguish $TYPE.property from $TYPE.method() by insisting in ()
STRING.upper() and STRING.lower() are methods.
Relevant to: #3023
diff --git a/bin/varnishtest/tests/v00058.vtc b/bin/varnishtest/tests/v00058.vtc
index c7f39e628..76fec5ec6 100644
--- a/bin/varnishtest/tests/v00058.vtc
+++ b/bin/varnishtest/tests/v00058.vtc
@@ -184,14 +184,14 @@ server s1 {
varnish v1 -vcl+backend {
sub vcl_deliver {
- set resp.http.l-proto = resp.proto.lower;
- set resp.http.u-proto = resp.proto.upper;
- set resp.http.l-req = req.url.lower;
- set resp.http.u-req = req.url.upper;
- set resp.http.l-mod = (req.url + "bar").lower;
- set resp.http.u-mod = (req.url + "bar").upper;
- set resp.http.uu-mod = (req.url + "bar").upper.upper;
- set resp.http.ul-mod = (req.url + "bar").upper.lower;
+ set resp.http.l-proto = resp.proto.lower();
+ set resp.http.u-proto = resp.proto.upper();
+ set resp.http.l-req = req.url.lower();
+ set resp.http.u-req = req.url.upper();
+ set resp.http.l-mod = (req.url + "bar").lower();
+ set resp.http.u-mod = (req.url + "bar").upper();
+ set resp.http.uu-mod = (req.url + "bar").upper().upper();
+ set resp.http.ul-mod = (req.url + "bar").upper().lower();
}
}
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 054b2ef56..29d82a23d 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -803,7 +803,13 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
/*--------------------------------------------------------------------
* SYNTAX:
* Expr4:
- * Expr5 [ '.' type_method() ]*
+ * Expr5 [ '.' (type_attribute | type_method()) ]*
+ *
+ * type_attributes is information already existing, requiring no
+ * processing or resource usage.
+ *
+ * type_methods are calls and may do (significant processing, change things,
+ * eat workspace etc.
*/
static const struct vcc_methods {
@@ -811,15 +817,16 @@ static const struct vcc_methods {
vcc_type_t type_to;
const char *method;
const char *impl;
+ int func;
} vcc_methods[] = {
//{ BACKEND, BOOL, "healthy", "VRT_Healthy(ctx, \v1, 0)" },
#define VRTSTVVAR(nm, vtype, ctype, dval) \
- { STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)"},
+ { STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)", 0},
#include "tbl/vrt_stv_var.h"
- { STRINGS, STRING, "upper", "VRT_UpperLowerStrands(ctx, \vT, 1)" },
- { STRINGS, STRING, "lower", "VRT_UpperLowerStrands(ctx, \vT, 0)" },
+ { STRINGS, STRING, "upper", "VRT_UpperLowerStrands(ctx, \vT, 1)", 1 },
+ { STRINGS, STRING, "lower", "VRT_UpperLowerStrands(ctx, \vT, 0)", 1 },
{ NULL, NULL, NULL, NULL},
};
@@ -859,6 +866,12 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
(*e)->fmt = STRINGS;
(*e)->nstr = 1;
}
+ if (vm->func) {
+ ExpectErr(tl, '(');
+ vcc_NextToken(tl);
+ ExpectErr(tl, ')');
+ vcc_NextToken(tl);
+ }
}
}
More information about the varnish-commit
mailing list