{"record":{"id":"d4351b19f452a584","repo":"babalae/better-genshin-impact","slug":"error-d4351b","errorCode":null,"errorMessage":"键谱延音符号前没有音符","messagePattern":"键谱延音符号前没有音符","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Music/Service/MusicScoreParser.cs","lineNumber":514,"sourceCode":"                index++;\n                var expectedClosing = current switch\n                {\n                    '(' => ')',\n                    '[' => ']',\n                    '{' => '}',\n                    _ => throw new InvalidOperationException()\n                };\n                node = new KeyboardNode(current, null, ParseKeyboardNodes(text, ref index, expectedClosing));\n            }\n            else if (current is ')' or ']' or '}')\n            {\n                throw new FormatException($\"键谱出现不匹配的括号：{current}\");\n            }\n            else if (current == '-')\n            {\n                if (nodes.Count == 0)\n                {\n                    throw new FormatException(\"键谱延音符号前没有音符\");\n                }\n\n                nodes[^1].Multiplier++;\n                index++;\n                continue;\n            }\n            else\n            {\n                node = new KeyboardNode('\\0', current, []);\n                index++;\n            }\n\n            while (index < text.Length && text[index] == '-')\n            {\n                node.Multiplier++;\n                index++;\n            }\n","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Music/Service/MusicScoreParser.cs#L496-L532","documentation":"A FormatException from ParseKeyboardNodes thrown when a '-' (sustain/tie) marker is encountered but the current node list is empty. '-' extends the previous note's Multiplier, so it is illegal at the start of a group or immediately after a group boundary with no preceding note.","triggerScenarios":"A keyboard-score string (or a bracketed group) begins with '-', e.g. '-Q', or a group like '(-Q)' where the tie precedes any note inside the group.","commonSituations":"Typo placing the tie before the note; a converter that emits a leading rest as '-'; copy-paste that dropped the first note but kept its tie.","solutions":["Ensure every '-' follows at least one note character within the same bracket scope (e.g. 'Q-' not '-Q').","Remove a stray leading '-' or add the missing note it was meant to extend.","Route through ParseAsync to get an InvalidScore.Error with the message.","Add a pre-parse lint that rejects a score (or group) whose first significant char is '-'."],"exampleFix":"// before\n\"notes\":\"-Q\"\n// after\n\"notes\":\"Q-\"","handlingStrategy":"validation","validationCode":"static bool NoLeadingTie(string s)\n{\n    // after the same preprocessing the parser applies\n    return !Regex.IsMatch(s, @\"(^|[(\\[{\\)\\]\\}-)-\");\n}","typeGuard":"null","tryCatchPattern":"var score = await parser.ParseAsync(path, root, ct);\nif (!string.IsNullOrEmpty(score.Error)) { Log.Warning(score.Error); continue; }","preventionTips":["Never start a score or group with '-'; place ties after a note.","Lint for a leading or post-bracket tie.","Use ParseAsync for InvalidScore handling."],"tags":["music-score","keyboard-score","input-validation","parsing"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}