diff --git a/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts b/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts index f4c824c..782bdce 100644 --- a/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts +++ b/src/core/dependencies/parser/CircomTemplateInputsVisitor.ts @@ -10,10 +10,13 @@ import { VarDefinitionContext, RhsValueContext, TemplateStmtContext, + BlockInstantiationExpressionContext, + DotExpressionContext, } from "@distributedlab/circom-parser"; import { InputData } from "../../../types/core"; import { HardhatZKitError } from "../../../errors"; +import { Reporter } from "../../../reporter"; /** * Visitor class for the {@link https://www.npmjs.com/package/@distributedlab/circom-parser | @distributedlab/circom-parser} package. @@ -134,6 +137,15 @@ export class CircomTemplateInputsVisitor extends CircomVisitor { const expressionVisitor = new CircomExpressionVisitor(true, this.vars); if (ctx.expression()) { + if ( + ctx.expression() instanceof BlockInstantiationExpressionContext || + ctx.expression() instanceof DotExpressionContext + ) { + Reporter?.reportUnsupportedExpression(ctx.expression().getText()); + + return [0n]; + } + const expressionResult = expressionVisitor.visitExpression(ctx.expression()); if (Array.isArray(expressionResult)) { diff --git a/src/reporter/ReporterFacade.ts b/src/reporter/ReporterFacade.ts index 4575f0a..79b7eea 100644 --- a/src/reporter/ReporterFacade.ts +++ b/src/reporter/ReporterFacade.ts @@ -15,6 +15,7 @@ import { VerifiersGenerationReporter, VKeyFilesGenerationReporter, ZKeyFilesGenerationReporter, + WarningsReporter, } from "./reporters"; import { createProgressBarProcessor } from "./ProgressBarProcessor"; @@ -31,6 +32,7 @@ class ReporterFacade { private _setupReporter!: SetupReporter; private _progressReporter!: ProgressReporter; private _ptauFileReporter!: PtauFileReporter; + private _warningsReporter!: WarningsReporter; private _circomCompilerReporter!: CircomCompilerReporter; private _circuitCompilationReporter!: CircuitCompilationReporter; private _verifiersGenerationReporter!: VerifiersGenerationReporter; @@ -55,6 +57,7 @@ class ReporterFacade { this._vKeyFilesGenerationReporter = new VKeyFilesGenerationReporter(quiet); this._zKeyFilesGenerationReporter = new ZKeyFilesGenerationReporter(quiet); this._circuitFilesResolvingReporter = new CircuitFilesResolvingReporter(quiet); + this._warningsReporter = new WarningsReporter(quiet); } public setQuiet(newValue: boolean) { @@ -219,6 +222,10 @@ class ReporterFacade { this._progressReporter.updateProgressBarValue(valueToAdd); } + public reportUnsupportedExpression(contextText: string) { + this._warningsReporter.reportUnsupportedExpression(contextText); + } + public verboseLog(namespace: string, formatterStr: string, logArgs: any[] = []) { debug(`hardhat-zkit:${namespace}`)(formatterStr, ...logArgs); } diff --git a/src/reporter/reporters/WarningsReporter.ts b/src/reporter/reporters/WarningsReporter.ts new file mode 100644 index 0000000..10cc82d --- /dev/null +++ b/src/reporter/reporters/WarningsReporter.ts @@ -0,0 +1,11 @@ +import { BaseReporter } from "@src/reporter/reporters/BaseReporter"; + +export class WarningsReporter extends BaseReporter { + public reportUnsupportedExpression(contextText: string) { + if (this.isQuiet()) return; + + console.warn( + `Expression structure: ${contextText} not supported if the expression is used to determine the dimension of input signal!`, + ); + } +} diff --git a/src/reporter/reporters/index.ts b/src/reporter/reporters/index.ts index 97c1d1d..49e25db 100644 --- a/src/reporter/reporters/index.ts +++ b/src/reporter/reporters/index.ts @@ -2,6 +2,7 @@ export * from "./BaseReporter"; export * from "./SetupReporter"; export * from "./ProgressReporter"; export * from "./PtauFileReporter"; +export * from "./WarningsReporter"; export * from "./CircomCompilerReporter"; export * from "./CircuitCompilationReporter"; export * from "./CircuitFilesResolvingReporter";