{"record":{"id":"5cffbb2597c63baf","repo":"microsoft/TypeScript","slug":"filename-line-col-message","errorCode":null,"errorMessage":"${fileName}(${line},${col}): ${message}","messagePattern":"\\$\\{fileName\\}\\(\\$\\{line\\},\\$\\{col\\}\\): \\$\\{message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/fourslashImpl.ts","lineNumber":4857,"sourceCode":"        files,\r\n        symlinks,\r\n        ranges,\r\n    };\r\n}\r\n\r\nfunction isConfig(file: FourSlashFile): boolean {\r\n    return Harness.getConfigNameFromFileName(file.fileName) !== undefined;\r\n}\r\n\r\nconst enum State {\r\n    none,\r\n    inSlashStarMarker,\r\n    inObjectMarker,\r\n}\r\n\r\nfunction reportError(fileName: string, line: number, col: number, message: string): never {\r\n    const errorMessage = fileName + \"(\" + line + \",\" + col + \"): \" + message;\r\n    throw new Error(errorMessage);\r\n}\r\n\r\nfunction recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: Map<string, Marker>, markers: Marker[]): Marker | undefined {\r\n    let markerValue;\r\n    try {\r\n        // Attempt to parse the marker value as JSON\r\n        markerValue = JSON.parse(\"{ \" + text + \" }\") as { name?: unknown; };\r\n    }\r\n    catch (e) {\r\n        reportError(fileName, location.sourceLine, location.sourceColumn, \"Unable to parse marker text \" + e.message);\r\n    }\r\n\r\n    if (markerValue === undefined) {\r\n        reportError(fileName, location.sourceLine, location.sourceColumn, \"Object markers can not be empty\");\r\n    }\r\n\r\n    const marker: Marker = {\r\n        fileName,\r","sourceCodeStart":4839,"sourceCodeEnd":4875,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/fourslashImpl.ts#L4839-L4875","documentation":"reportError is a generic formatting helper (not a single condition) that throws an Error with the form fileName(line,col): message. It is invoked from seven sites in fourslash test parsing: unparseable object markers, empty object markers, duplicate markers, range-end-without-start, unterminated ranges, and unterminated markers. The message text after the position prefix identifies which structural problem was found in the test source.","triggerScenarios":"Any malformed fourslash marker/range syntax during parseFileContent: object marker text that fails JSON.parse, an empty object marker, two markers sharing the same name, a range close [| without a matching open, a [| ... range never closed, or a /*<...>*/ marker never closed.","commonSituations":"Hand-editing fourslash test files and breaking marker syntax — e.g. unbalanced [| |] pairs, malformed JSON inside object markers, or duplicate marker names across the file. The error pinpoints the line and column of the offending token.","solutions":["Use the line,column in the message to jump to the exact token in the test file.","Match the trailing message to the condition: 'Unable to parse marker text' -> fix the JSON in the object marker; 'Object markers can not be empty' -> add content; 'Marker ... is duplicated' -> rename one; 'Found range end with no matching start' -> add an opening [|; 'Unterminated range' / 'Unterminated marker' -> add the matching close.","Re-validate the file with a fourslash linter or by comparing against a known-good test."],"exampleFix":"// before — unterminated range\n// [|const x = 1;\n// const y = 2;\n// after\n// [|const x = 1;|]\n// const y = 2;","handlingStrategy":"validation","validationCode":"// Validate marker/range balance before running the test\nfunction validateMarkers(content: string) {\n    const openRanges = (content.match(/\\[\\|/g) || []).length;\n    const closeRanges = (content.match(/\\|\\]/g) || []).length;\n    if (openRanges !== closeRanges) throw new Error(`Unbalanced ranges: ${openRanges} open vs ${closeRanges} close`);\n    const openMarkers = (content.match(/\\/\\*</g) || []).length;\n    const closeMarkers = (content.match(/\\*>\\//g) || []).length;\n    if (openMarkers !== closeMarkers) throw new Error(`Unbalanced markers`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always close every [| with a |] and every /*<...>*/ marker in the same edit.","Use a fourslash-aware editor extension or linter to catch malformed marker/range syntax before running."],"tags":["fourslash","test-parsing","marker-syntax","range-syntax"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}