{"record":{"id":"3155dd6767060cb3","repo":"stride3d/stride","slug":"msg","errorCode":null,"errorMessage":"{msg}","messagePattern":"\\{msg\\}","errorType":"exception","errorClass":"LexerException","httpStatus":null,"severity":"warning","filePath":"sources/shaders/Stride.Shaders.Parsers/CppNet/JoinReader.cs","lineNumber":88,"sourceCode":"            if(uptr > 0)\n                return unget[--uptr];\n            return _in.Read();\n        }\n\n        private void _unread(int c)\n        {\n            if(c != -1)\n                unget[uptr++] = c;\n            System.Diagnostics.Debug.Assert(uptr <= unget.Length,\n                    \"JoinReader ungets too many characters\");\n        }\n\n        protected void warning(String msg)\n        {\n            if(source != null)\n                source.warning(msg);\n            else\n                throw new LexerException(msg);\n        }\n\n        private char trigraph(char raw, char repl)\n        {\n            if(trigraphs) {\n                if(warnings)\n                    warning(\"trigraph ??\" + raw + \" converted to \" + repl);\n                return repl;\n            } else {\n                if(warnings)\n                    warning(\"trigraph ??\" + raw + \" ignored\");\n                _unread(raw);\n                _unread('?');\n                return '?';\n            }\n        }\n\n        private int _read()","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/CppNet/JoinReader.cs#L70-L106","documentation":"JoinReader.warning reports lexer warnings (e.g. trigraph conversion/ignoring) by forwarding them to the current LexerSource; if no source is attached (source == null), it throws LexerException with the warning text instead. In other words, a merely warning-grade condition becomes a fatal error when the reader has no source to report through.","triggerScenarios":"Reading input through a JoinReader that was never init()-ed with a Preprocessor/LexerSource (or whose source was detached) while a trigraph sequence '??x' is encountered and trigraph warnings are enabled (Warning.TRIGRAPHS).","commonSituations":"Constructing a JoinReader manually without calling init(pp, source); preprocessing shader code containing legacy '??(' style trigraph sequences on a reader without a source; ported C preprocessor code paths where the source is set later than first read.","solutions":["Call init(preprocessor, lexerSource) on the JoinReader before reading so warnings route to the source's warning handler.","Remove or escape the trigraph sequence (e.g. '??(' -> '( ') from the input text.","Disable trigraph warnings via the preprocessor feature/warning flags (Feature.TRIGRAPHS / Warning.TRIGRAPHS) if trigraphs are intentional.","Install a PreprocessorListener so LexerSource.warning logs instead of propagating."],"exampleFix":"// before: reader created without a source; a trigraph warning throws\nvar reader = new JoinReader(stream);\n// after: attach source so warnings are reported, not thrown\nvar reader = new JoinReader(stream);\nreader.init(preprocessor, new LexerSource(reader, \"shader.sdsl\"));","handlingStrategy":"try-catch","validationCode":"// Ensure the reader is wired to a source before reading\nif (!readerIsInitialized)\n    throw new InvalidOperationException(\"JoinReader must be init(pp, source)-ed before read()\");","typeGuard":null,"tryCatchPattern":"try\n{\n    int c = reader.read();\n}\ncatch (LexerException ex)\n{\n    logger.Warn($\"Trigraph/diagnostic while lexing: {ex.Message}\");\n}","preventionTips":["Always call init(preprocessor, lexerSource) before the first read().","Enable Feature.TRIGRAPHS/WARNING flags deliberately; avoid raw '??x' sequences in shader sources.","Install a PreprocessorListener so warnings never escalate to exceptions."],"tags":["lexer","trigraph","preprocessor"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}