From fdbf465edae84e7b4f907a45c2473f066fd2fd89 Mon Sep 17 00:00:00 2001
From: Teng Huang <haterh@gmail.com>
Date: Wed, 27 Oct 2021 00:20:45 +0800
Subject: [PATCH] Fix array method names with parens (#3181) (#3183)

---
 docs/CONTRIBUTORS               |  1 +
 src/verilog.y                   |  2 +-
 test_regress/t/t_assoc_method.v | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS
index 1a86f4570..898bd3ba7 100644
--- a/docs/CONTRIBUTORS
+++ b/docs/CONTRIBUTORS
@@ -88,6 +88,7 @@ Sergi Granell
 Stefan Wallentowitz
 Stephen Henry
 Steven Hugg
+Teng Huang
 Tim Snyder
 Tobias Rosenkranz
 Tobias Wölfel
diff --git a/src/verilog.y b/src/verilog.y
index 8cca67a2c..7d6e44d16 100644
--- a/src/verilog.y
+++ b/src/verilog.y
@@ -4117,7 +4117,7 @@ array_methodNoRoot<nodeFTaskRefp>:
 	;
 
 array_methodWith<nodep>:
-		array_methodNoRoot			{ $$ = $1; }
+		array_methodNoRoot parenE		{ $$ = $1; }
 	|	array_methodNoRoot parenE yWITH__PAREN '(' expr ')'
 			{ $$ = new AstWithParse($3, false, $1, $5); }
 	|	array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')'
diff --git a/test_regress/t/t_assoc_method.v b/test_regress/t/t_assoc_method.v
index 684e90c68..e4d87f611 100644
--- a/test_regress/t/t_assoc_method.v
+++ b/test_regress/t/t_assoc_method.v
@@ -119,6 +119,26 @@ module t (/*AUTOARG*/);
       i = qe.xor;
       `checkh(i, 32'b0);
 
+      i = q.and();
+      `checkh(i, 32'b1000);
+      i = q.and() with (item + 1);
+      `checkh(i, 32'b1001);
+      i = q.or();
+      `checkh(i, 32'b1110);
+      i = q.or() with (item + 1);
+      `checkh(i, 32'b1111);
+      i = q.xor();
+      `checkh(i, 32'b0110);
+      i = q.xor() with (item + 1);
+      `checkh(i, 32'b0110);
+
+      i = qe.and();
+      `checkh(i, 32'b0);
+      i = qe.or();
+      `checkh(i, 32'b0);
+      i = qe.xor();
+      `checkh(i, 32'b0);
+
       $write("*-* All Finished *-*\n");
       $finish;
    end