{"record":{"id":"ac851fed2c0d0736","repo":"stride3d/stride","slug":"unsupported-float","errorCode":null,"errorMessage":"Unsupported float","messagePattern":"Unsupported float","errorType":"validation","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs","lineNumber":378,"sourceCode":"            BoolLiteral lit => ScalarType.Boolean,\n            IntegerLiteral lit => lit.Suffix switch\n            {\n                //{ Signed: true, Size: 8 } => ScalarType.SByte,\n                //{ Signed: true, Size: 16 } => ScalarType.Short,\n                { Signed: true, Size: 32 } => ScalarType.Int,\n                { Signed: true, Size: 64 } => ScalarType.Int64,\n                //{ Signed: false, Size: 8 } => ScalarType.UByte,\n                //{ Signed: false, Size: 16 } => ScalarType.UShort,\n                { Signed: false, Size: 32 } => ScalarType.UInt,\n                { Signed: false, Size: 64 } => ScalarType.UInt64,\n                _ => throw new NotImplementedException(\"Unsupported integer suffix\")\n            },\n            FloatLiteral lit => lit.Suffix.Size switch\n            {\n                //16 => ScalarType.Half,\n                32 => ScalarType.Float,\n                64 => ScalarType.Double,\n                _ => throw new NotImplementedException(\"Unsupported float\")\n            },\n            _ => throw new NotSupportedException($\"Unsupported literal type: {literal.GetType()}\"),\n        };\n    }\n}\n","sourceCodeStart":360,"sourceCodeEnd":384,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs#L360-L384","documentation":"ComputeLiteralType maps a FloatLiteral's suffix Size to ScalarType: only 32 (Float) and 64 (Double) are handled; the 16 (Half) arm is commented out. Any other size throws NotImplementedException('Unsupported float').","triggerScenarios":"Creating a FloatLiteral whose Suffix.Size is not 32 or 64 — e.g. a half-precision literal with Size 16 — and letting ComputeLiteralType run via CompileConstantLiteral (literal.Type not pre-set).","commonSituations":"Constructing half-precision float literals (Suffix Size 16) for half shader variables; custom literal construction in tooling that uses exotic float sizes.","solutions":["Use FloatLiteral suffix sizes 32 or 64 (float/double) in this pipeline","Pre-assign literal.Type before calling CompileConstantLiteral so ComputeLiteralType is skipped","Uncomment the //16 => ScalarType.Half arm (and ensure ScalarType.Half plus corresponding emission in CompileConstantLiteral) to support half literals"],"exampleFix":"// before\nvar lit = new FloatLiteral(new(16, true, true), 1.5f, location); // Size 16\nCompileConstantLiteral(lit); // throws: Unsupported float\n// after\nvar lit = new FloatLiteral(new(32, true, true), 1.5f, location);\nCompileConstantLiteral(lit); // ScalarType.Float","handlingStrategy":"validation","validationCode":"bool IsSupportedFloatSuffix(LiteralSuffix s) => s.Size is 32 or 64;","typeGuard":"static bool IsFloat32Or64(FloatLiteral l) => l.Suffix.Size is 32 or 64;","tryCatchPattern":"try\n{\n    var result = context.CompileConstantLiteral(floatLiteral);\n}\ncatch (NotImplementedException ex) when (ex.Message == \"Unsupported float\")\n{\n    // widen half to float and retry\n    var widened = new FloatLiteral(new(32, true, true), (float)floatLiteral.DoubleValue, default);\n    var result = context.CompileConstantLiteral(widened);\n}","preventionTips":["Only create FloatLiterals with Suffix.Size 32 or 64","Set literal.Type explicitly for half constants so ComputeLiteralType is bypassed","Avoid half-precision literals until the commented Half arm is restored","Keep Suffix.Size in sync with the actual precision needed"],"tags":["literal","float","not-implemented","shader-compilation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}