Skip to content

Commit

Permalink
Updated version. Fixed typo. Handled errors gracefully. Handled null …
Browse files Browse the repository at this point in the history
…values
  • Loading branch information
KyrylR committed Nov 1, 2024
1 parent 2825eab commit 9d454fe
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 13 additions & 5 deletions src/core/dependencies/parser/CircomFilesParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/dependencies/parser/CircomFilesVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class CircomFilesVisitor extends CircomVisitor<void> {
}

this.fileData.templates[ctx.ID().getText()] = {
parameters: parseSimpleIdentifierList(ctx._argNames),
parameters: ctx._argNames ? parseSimpleIdentifierList(ctx._argNames) : [],
isCustom: !!ctx.CUSTOM(),
parallel: !!ctx.PARALLEL(),
context: ctx,
Expand Down
4 changes: 2 additions & 2 deletions src/core/dependencies/parser/CircomTemplateInputsVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor<void> {
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})`,
Expand Down Expand Up @@ -538,7 +538,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor<void> {
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})`,
Expand Down
2 changes: 1 addition & 1 deletion src/types/core/dependencies/parser/circom-files-visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export enum ErrorType {
ComplexAccessNotSupported,
AssigneeNotDeclared,
QUOOperationNotSupported,
ReachedUnkownOperation,
ReachedUnknownOperation,
InvalidIncDecOperation,
}

Expand Down

0 comments on commit 9d454fe

Please sign in to comment.