[PATCH v2] vbscript: Allow keywords to be used as function name.

Robert Wilhelm robert.wilhelm at gmx.net
Thu Nov 5 16:12:15 CST 2020


Signed-off-by: Robert Wilhelm <robert.wilhelm at gmx.net>
---
v2: Jacek's patch which puts logic in one place.
---
 dlls/vbscript/parser.y       | 10 +++++-----
 dlls/vbscript/tests/lang.vbs | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 942e76459c2..7c749b5ef77 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -490,11 +490,11 @@ ArgumentDecl
 /* these keywords may also be an identifier, depending on context */
 Identifier
     : tIdentifier    { $$ = $1; }
-    | tDEFAULT       { $$ = $1; }
-    | tERROR         { $$ = $1; }
-    | tEXPLICIT      { $$ = $1; }
-    | tPROPERTY      { $$ = $1; }
-    | tSTEP          { $$ = $1; }
+    | tDEFAULT       { ctx->last_token = tIdentifier; $$ = $1; }
+    | tERROR         { ctx->last_token = tIdentifier; $$ = $1; }
+    | tEXPLICIT      { ctx->last_token = tIdentifier; $$ = $1; }
+    | tPROPERTY      { ctx->last_token = tIdentifier; $$ = $1; }
+    | tSTEP          { ctx->last_token = tIdentifier; $$ = $1; }

 /* Most statements accept both new line and ':' as separators */
 StSep
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 65f8a458cd7..570bb7fbcb3 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -1631,9 +1631,31 @@ sub test_identifiers
     Dim step
     step = "xx"
     Call ok(step = "xx", "step = " & step & " expected ""xx""")
+
+    Dim property
+    property = "xx"
+    Call ok(property = "xx", "property = " & property & " expected ""xx""")
 end sub
 call test_identifiers()

+Class class_test_identifiers_as_function_name
+    Sub Property ( par )
+    End Sub
+
+    Function Error( par )
+    End Function
+
+    Sub Default ()
+    End Sub
+
+    Function Explicit (par)
+        Explicit = par
+    End Function
+
+    Sub Step ( default )
+    End Sub
+End Class
+
 sub test_dotIdentifiers
     ' test keywords that can also be an identifier after a dot
     Call ok(testObj.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
--
2.26.2





More information about the wine-devel mailing list