{"record":{"id":"648850ea01916284","repo":"BabylonJS/Babylon.js","slug":"uniforms-must-have-a-type-uniformline","errorCode":null,"errorMessage":"`Uniforms must have a type: '${uniformLine}'`","messagePattern":"`Uniforms must have a type: '(.+?)'`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/utils/buildTools/shaderConverter.ts","lineNumber":145,"sourceCode":"    const uniformRegExp = new RegExp(/(\\/\\/\\s*\\{.*\\}\\s*(?:\\r\\n|\\r|\\n)+)?(uniform .*)/gm);\r\n    const uniformGroups = fragmentShader.matchAll(uniformRegExp);\r\n    for (const matches of uniformGroups) {\r\n        const annotationJSON = matches[1];\r\n        const uniformLine = matches[2];\r\n\r\n        if (!uniformLine) {\r\n            throw new Error(\"Uniform line not found\");\r\n        }\r\n\r\n        const uniformLineMatches = new RegExp(/^uniform\\s+(\\w+)\\s+(\\w+)\\s*;?/gm).exec(uniformLine);\r\n        if (!uniformLineMatches || uniformLineMatches.length < 3) {\r\n            throw new Error(`Uniforms must have a type and a name: '${uniformLine}'`);\r\n        }\r\n        const uniformTypeString = uniformLineMatches[1];\r\n        const uniformName = uniformLineMatches[2];\r\n\r\n        if (!uniformTypeString) {\r\n            throw new Error(`Uniforms must have a type: '${uniformLine}'`);\r\n        }\r\n        if (!uniformName) {\r\n            throw new Error(`Uniforms must have a name: '${uniformLine}'`);\r\n        }\r\n\r\n        // Convert to ConnectionPointType\r\n        let type: ConnectionPointType;\r\n        switch (uniformTypeString) {\r\n            case \"float\":\r\n                type = ConnectionPointType.Float;\r\n                break;\r\n            case \"sampler2D\":\r\n                type = ConnectionPointType.Texture;\r\n                break;\r\n            case \"vec3\":\r\n                type = ConnectionPointType.Color3;\r\n                break;\r\n            case \"vec4\":\r","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/utils/buildTools/shaderConverter.ts#L127-L163","documentation":"The uniform regex matched, but the type capture group is empty — the declaration has a name but no recognizable type word. The tool needs the type to map to a ConnectionPointType, so it throws with the offending line.","triggerScenarios":"A uniform declaration like 'uniform  someName;' or whitespace/formatting that prevents the (\\w+) type capture from matching.","commonSituations":"Corrupted or partially deleted uniform lines; macro-based types that the regex cannot capture (e.g. uniform PRECISION float x) resolved differently at parse time.","solutions":["Ensure the uniform line includes an explicit concrete GLSL type (float, vec2, etc.).","Avoid macros/typedefs in uniform type positions; inline the concrete type.","Inspect the line echoed in the error message and fix the declaration."],"exampleFix":"// before\nuniform  textureSize;\n// after\nuniform vec2 textureSize;","handlingStrategy":"validation","validationCode":"src.split('\\n').forEach((l, i) => { const m = l.trim().match(/^uniform\\s+(\\w+)\\s+(\\w+)\\s*;?$/); if (l.trim().startsWith('uniform') && (!m || !m[1])) console.error(`Uniform missing type at line ${i+1}`); });","typeGuard":null,"tryCatchPattern":"try { await ConvertShader(path, ...); } catch (e) { const m = e.message.match(/Uniforms must have a type: '(.*)'/); if (m) { addConcreteType(m[1]); } else { throw e; } }","preventionTips":["Use concrete GLSL types (float, vec2, ...) not macros in uniform declarations.","Never leave a uniform declaration incomplete.","Review shader edits for deleted type tokens."],"tags":["glsl","uniform-parsing","syntax"],"backgroundTag":"uniform-type-missing","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}