diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index 6933b39b4b2..a306bf93546 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -322,7 +322,7 @@ function parseNoirFile(fileContent: string): ParsedContent { } { - const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]+)(;)?/) || []; + const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || []; if (name && value) { const [, indexName] = name.match(/GENERATOR_INDEX__(\w+)/) || []; if (indexName) { @@ -336,6 +336,10 @@ function parseNoirFile(fileContent: string): ParsedContent { expression = { name, content: [value] }; } return; + } else if (name) { + // This case happens if we have only a name, with the value being on the next line + expression = { name, content: [] }; + return; } } @@ -389,8 +393,11 @@ function evaluateExpressions(expressions: [string, string][]): { [key: string]: // We make some space around the parentheses, so that constant numbers are still split. .replace(/\(/g, '( ') .replace(/\)/g, ' )') + // We also make some space around common operators + .replace(/\+/g, ' + ') + .replace(/(? (isNaN(+term) ? term : `BigInt('${term}')`)) // .. also, we convert the known bigints to BigInts.