From 9d454fe9ddcc2c8681ce27b7e5c24a19f24a8045 Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Fri, 1 Nov 2024 11:47:34 +0200 Subject: [PATCH] Updated version. Fixed typo. Handled errors gracefully. Handled null values --- package-lock.json | 4 ++-- package.json | 2 +- .../dependencies/parser/CircomFilesParser.ts | 18 +++++++++++++----- .../dependencies/parser/CircomFilesVisitor.ts | 2 +- .../parser/CircomTemplateInputsVisitor.ts | 4 ++-- .../parser/circom-files-visitor.ts | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd34e70..7b8786e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solarity/hardhat-zkit", - "version": "0.4.11", + "version": "0.4.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@solarity/hardhat-zkit", - "version": "0.4.11", + "version": "0.4.12", "license": "MIT", "workspaces": [ "test/fixture-projects/*" diff --git a/package.json b/package.json index 752b042..111118d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/hardhat-zkit", - "version": "0.4.11", + "version": "0.4.12", "description": "The ultimate TypeScript environment for Circom development", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/src/core/dependencies/parser/CircomFilesParser.ts b/src/core/dependencies/parser/CircomFilesParser.ts index 1509097..6ad61bb 100644 --- a/src/core/dependencies/parser/CircomFilesParser.ts +++ b/src/core/dependencies/parser/CircomFilesParser.ts @@ -6,7 +6,7 @@ import { CircuitsCompileCache } from "../../../cache"; import { Reporter } from "../../../reporter"; import { VisitorError } from "../parser/VisitorError"; -import { CircomResolvedFile, InputData, ResolvedFileData } from "../../../types/core"; +import { CircomResolvedFile, ErrorType, InputData, ResolvedFileData } from "../../../types/core"; /** * A parser class for handling Circom files and extracting relevant data. @@ -61,8 +61,12 @@ export class CircomFilesParser { circomFilesVisitor.visit(context); - if (circomFilesVisitor.errors.length > 0) { - throw new VisitorError(circomFilesVisitor.errors); + const visitorErrors = circomFilesVisitor.errors.filter( + (error) => error.type !== ErrorType.ComplexAccessNotSupported, + ); + + if (visitorErrors.length > 0) { + throw new VisitorError(visitorErrors); } this._cache.set(contentHash, { parsedFileData: circomFilesVisitor.fileData }); @@ -97,8 +101,12 @@ export class CircomFilesParser { circomTemplateInputsVisitor.startParse(); - if (circomTemplateInputsVisitor.errors.length > 0) { - throw new VisitorError(circomTemplateInputsVisitor.errors); + const visitorErrors = circomTemplateInputsVisitor.errors.filter( + (error) => error.type !== ErrorType.ComplexAccessNotSupported, + ); + + if (visitorErrors.length > 0) { + throw new VisitorError(visitorErrors); } return circomTemplateInputsVisitor.templateInputs; diff --git a/src/core/dependencies/parser/CircomFilesVisitor.ts b/src/core/dependencies/parser/CircomFilesVisitor.ts index 27abd0d..00fbf12 100644 --- a/src/core/dependencies/parser/CircomFilesVisitor.ts +++ b/src/core/dependencies/parser/CircomFilesVisitor.ts @@ -74,7 +74,7 @@ export class CircomFilesVisitor extends CircomVisitor { } this.fileData.templates[ctx.ID().getText()] = { - parameters: parseSimpleIdentifierList(ctx._argNames), + parameters: ctx._argNames ? parseSimpleIdentifierList(ctx._argNames) : [], isCustom: !!ctx.CUSTOM(), parallel: !!ctx.PARALLEL(), context: ctx, diff --git a/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts b/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts index e75094f..eed0b7f 100644 --- a/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts +++ b/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts @@ -477,7 +477,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor { break; default: this.errors.push({ - type: ErrorType.ReachedUnkownOperation, + type: ErrorType.ReachedUnknownOperation, context: ctx, fileIdentifier: this.fileIdentifier, message: `Invalid operation type ${ctx.ASSIGNMENT_WITH_OP().getText()} (${ctx.start.line}:${ctx.start.column})`, @@ -538,7 +538,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor { break; default: this.errors.push({ - type: ErrorType.ReachedUnkownOperation, + type: ErrorType.ReachedUnknownOperation, context: ctx, fileIdentifier: this.fileIdentifier, message: `Invalid operation type ${ctx.SELF_OP().getText()} (${ctx.start.line}:${ctx.start.column})`, diff --git a/src/types/core/dependencies/parser/circom-files-visitor.ts b/src/types/core/dependencies/parser/circom-files-visitor.ts index 0d6d330..aed9dfd 100644 --- a/src/types/core/dependencies/parser/circom-files-visitor.ts +++ b/src/types/core/dependencies/parser/circom-files-visitor.ts @@ -23,7 +23,7 @@ export enum ErrorType { ComplexAccessNotSupported, AssigneeNotDeclared, QUOOperationNotSupported, - ReachedUnkownOperation, + ReachedUnknownOperation, InvalidIncDecOperation, }