From 9ca25d5fd901cd7768ad630fa613fd2f4c0ae32d Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 12 Feb 2024 13:56:33 +0000 Subject: [PATCH 1/2] Throw an error if a variable begins with _ --- src/transformers/visitors/checks/unsupportedVisitor.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/transformers/visitors/checks/unsupportedVisitor.ts b/src/transformers/visitors/checks/unsupportedVisitor.ts index a36de160f..bb2458080 100644 --- a/src/transformers/visitors/checks/unsupportedVisitor.ts +++ b/src/transformers/visitors/checks/unsupportedVisitor.ts @@ -78,4 +78,14 @@ export default { ); }, }, + + VariableDeclaration: { + enter(node: any) { + if (node.name.startsWith('_')) + throw new ZKPError( + `Zokrates does not support variables that begin with _ such as as _value.`, + node + ); + }, + }, }; From ea39da81ea507fe1e3f6719cdda5bf78fc6c61d2 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 12 Feb 2024 14:38:16 +0000 Subject: [PATCH 2/2] fix error --- src/transformers/visitors/checks/unsupportedVisitor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/visitors/checks/unsupportedVisitor.ts b/src/transformers/visitors/checks/unsupportedVisitor.ts index bb2458080..99a99a688 100644 --- a/src/transformers/visitors/checks/unsupportedVisitor.ts +++ b/src/transformers/visitors/checks/unsupportedVisitor.ts @@ -83,7 +83,7 @@ export default { enter(node: any) { if (node.name.startsWith('_')) throw new ZKPError( - `Zokrates does not support variables that begin with _ such as as _value.`, + `Zokrates does not support variables that begin with an underscore such as as _value.`, node ); },