@@ -63,7 +63,7 @@ export class ExpressionHelper {
63
63
64
64
const result = visitor . visitExpression ( this . _expressionContext ) ;
65
65
66
- if ( result === null ) {
66
+ if ( result === null || result === undefined ) {
67
67
return [ null , visitor . getErrors ( ) ] ;
68
68
}
69
69
@@ -91,7 +91,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
91
91
if ( ctx . TERNARY_CONDITION ( ) && ctx . TERNARY_ALTERNATIVE ( ) ) {
92
92
const conditionResult = this . visit ( ctx . _cond ) ;
93
93
94
- if ( conditionResult === null ) {
94
+ if ( conditionResult === null || conditionResult === undefined ) {
95
95
this . addError (
96
96
"Failed to resolve the condition of a ternary expression" ,
97
97
ctx . _cond ,
@@ -124,7 +124,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
124
124
const variableValue =
125
125
this . variableContext [ ctx . identifierStatement ( ) . ID ( ) . getText ( ) ] ;
126
126
127
- if ( variableValue === undefined ) {
127
+ if ( variableValue === undefined || variableValue === null ) {
128
128
this . addError (
129
129
`Variable ${ ctx . identifierStatement ( ) . ID ( ) . getText ( ) } is not defined` ,
130
130
ctx . identifierStatement ( ) ,
@@ -153,7 +153,10 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
153
153
154
154
const variableName = ctx . identifierStatement ( ) . ID ( ) . getText ( ) + reference ;
155
155
156
- if ( this . variableContext [ variableName ] === undefined ) {
156
+ if (
157
+ this . variableContext [ variableName ] === undefined ||
158
+ this . variableContext [ variableName ] === null
159
+ ) {
157
160
this . addError (
158
161
`Variable ${ variableName } is not defined` ,
159
162
ctx . identifierStatement ( ) ,
@@ -184,7 +187,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
184
187
for ( let i = 0 ; i < ctx . expressionList ( ) . expression_list ( ) . length ; i ++ ) {
185
188
const resolvedItem = this . visit ( ctx . expressionList ( ) . expression ( i ) ) ;
186
189
187
- if ( ! resolvedItem ) {
190
+ if ( resolvedItem === null || resolvedItem === undefined ) {
188
191
this . addError (
189
192
`Failed to resolve the ${ i } element of an array.` ,
190
193
ctx . expressionList ( ) . expression ( i ) ,
@@ -220,7 +223,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
220
223
221
224
const firstExpression = this . visit ( ctx . expression ( 0 ) ) ;
222
225
223
- if ( firstExpression === null ) {
226
+ if ( firstExpression === null || firstExpression === undefined ) {
224
227
this . addError (
225
228
"Failed to resolve the first expression of an operation" ,
226
229
ctx . expression ( 0 ) ,
@@ -256,7 +259,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor<CircomValueType | null> {
256
259
257
260
const secondExpression = this . visit ( ctx . expression ( 1 ) ) ;
258
261
259
- if ( secondExpression === null ) {
262
+ if ( secondExpression === null || secondExpression === undefined ) {
260
263
this . addError (
261
264
"Failed to resolve the second expression of an operation" ,
262
265
ctx . expression ( 1 ) ,
0 commit comments