diff --git a/apps/noir-compiler/src/app/services/noirParser.ts b/apps/noir-compiler/src/app/services/noirParser.ts index daf8190663..5b5ebcf0d2 100644 --- a/apps/noir-compiler/src/app/services/noirParser.ts +++ b/apps/noir-compiler/src/app/services/noirParser.ts @@ -136,12 +136,6 @@ class NoirParser { } } - extractReturnType(line) { - const returnMatch = line.match(/->\s*([a-zA-Z_][a-zA-Z0-9_:<>, ]*)/); - - return returnMatch ? returnMatch[1].trim() : null; - } - checkFunctionReturnType(line, lineIdx, originalLine) { const returnMatch = line.match(/->\s*([a-zA-Z_][a-zA-Z0-9_:<>, ]*)/); @@ -207,19 +201,27 @@ class NoirParser { } isValidNoirType(type) { - // Basic types - if (this.noirTypes.includes(type)) return true; - - // Array types - if (type.includes('[') && type.includes(']')) { - const baseType = type.match(/\[(.*?);/)?.[1]; - return baseType && this.noirTypes.includes(baseType); + // Handle visibility modifiers (pub/priv) and extract base type + const typeParts = type.split(/\s+/); + const baseType = typeParts[typeParts.length - 1]; // Get last part after any modifiers + + if (this.noirTypes.includes(baseType)) return true; + if (baseType.includes('[') && baseType.includes(']')) { + const innerTypeMatch = baseType.match(/\[(.*?);/); + if (innerTypeMatch) { + const innerType = innerTypeMatch[1].trim(); + return this.noirTypes.includes(innerType); + } + return false; } - - // Generic types or custom types (not supported for now) return false; } + extractReturnType(line) { + const returnMatch = line.match(/->\s*((?:pub\s+)?[a-zA-Z_][a-zA-Z0-9_:<>, ]*)/); + return returnMatch ? returnMatch[1].trim() : null; + } + calculatePosition(line, startColumn, endColumn) { return { start: {