@@ -63,7 +63,7 @@ export class ExpressionHelper {
6363
6464 const result = visitor . visitExpression ( this . _expressionContext ) ;
6565
66- if ( result === null ) {
66+ if ( result === null || result === undefined ) {
6767 return [ null , visitor . getErrors ( ) ] ;
6868 }
6969
@@ -91,7 +91,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
9191 if ( ctx . TERNARY_CONDITION ( ) && ctx . TERNARY_ALTERNATIVE ( ) ) {
9292 const conditionResult = this . visit ( ctx . _cond ) ;
9393
94- if ( conditionResult === null ) {
94+ if ( conditionResult === null || conditionResult === undefined ) {
9595 this . addError (
9696 "Failed to resolve the condition of a ternary expression" ,
9797 ctx . _cond ,
@@ -124,7 +124,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
124124 const variableValue =
125125 this . variableContext [ ctx . identifierStatement ( ) . ID ( ) . getText ( ) ] ;
126126
127- if ( variableValue === undefined ) {
127+ if ( variableValue === undefined || variableValue === null ) {
128128 this . addError (
129129 `Variable ${ ctx . identifierStatement ( ) . ID ( ) . getText ( ) } is not defined` ,
130130 ctx . identifierStatement ( ) ,
@@ -153,7 +153,10 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
153153
154154 const variableName = ctx . identifierStatement ( ) . ID ( ) . getText ( ) + reference ;
155155
156- if ( this . variableContext [ variableName ] === undefined ) {
156+ if (
157+ this . variableContext [ variableName ] === undefined ||
158+ this . variableContext [ variableName ] === null
159+ ) {
157160 this . addError (
158161 `Variable ${ variableName } is not defined` ,
159162 ctx . identifierStatement ( ) ,
@@ -184,7 +187,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
184187 for ( let i = 0 ; i < ctx . expressionList ( ) . expression_list ( ) . length ; i ++ ) {
185188 const resolvedItem = this . visit ( ctx . expressionList ( ) . expression ( i ) ) ;
186189
187- if ( ! resolvedItem ) {
190+ if ( resolvedItem === null || resolvedItem === undefined ) {
188191 this . addError (
189192 `Failed to resolve the ${ i } element of an array.` ,
190193 ctx . expressionList ( ) . expression ( i ) ,
@@ -220,7 +223,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
220223
221224 const firstExpression = this . visit ( ctx . expression ( 0 ) ) ;
222225
223- if ( firstExpression === null ) {
226+ if ( firstExpression === null || firstExpression === undefined ) {
224227 this . addError (
225228 "Failed to resolve the first expression of an operation" ,
226229 ctx . expression ( 0 ) ,
@@ -256,7 +259,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
256259
257260 const secondExpression = this . visit ( ctx . expression ( 1 ) ) ;
258261
259- if ( secondExpression === null ) {
262+ if ( secondExpression === null || secondExpression === undefined ) {
260263 this . addError (
261264 "Failed to resolve the second expression of an operation" ,
262265 ctx . expression ( 1 ) ,
0 commit comments