From 8c5affe9a57bc9fbf0b934f656f5fa5900f8fc2d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 15 Jul 2024 01:09:19 +0900 Subject: [PATCH] updated the tuple handling slightly --- lib/read.c | 9 +++++---- t/var-5001.err | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/read.c b/lib/read.c index d5c2c89..e921468 100644 --- a/lib/read.c +++ b/lib/read.c @@ -905,10 +905,13 @@ static HCL_INLINE int can_binop_list (hcl_t* hcl) HCL_ASSERT (hcl, hcl->c->r.st != HCL_NULL); rstl = hcl->c->r.st; + cc = (hcl_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv); - if (rstl->count <= 0) + if (rstl->count <= 0 || cc == HCL_CONCODE_TUPLE) { - /* allowed but it must be treated like a normal identifier */ + /* allowed but it must be treated like a normal identifier. + * in case of the tuple, chain_to_list() rejects binop symbols. + * so let this routine to allow it as a normal indentifier. */ return 1; } @@ -917,8 +920,6 @@ static HCL_INLINE int can_binop_list (hcl_t* hcl) /* repeated delimiters - e.g (a ++ ++ ...) (a : := ... ) */ if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0; - cc = (hcl_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv); - /* assignment only in XLIST */ if (cc != HCL_CONCODE_XLIST) return 0; diff --git a/t/var-5001.err b/t/var-5001.err index 3894798..d2efe0f 100644 --- a/t/var-5001.err +++ b/t/var-5001.err @@ -44,7 +44,7 @@ class A [ [ [a] ] ] { ##ERROR: syntax error - not variable name } --- -class A [ a + ] { ##ERROR: syntax error - prohibited binary operator - + +class A [ a + ] { ##ERROR: syntax error - invalid name - not symbol in tuple - + } ---