From b1ac3756227f4421c60faeb85f696e456cc1804c Mon Sep 17 00:00:00 2001 From: Lexikos Date: Sat, 20 Apr 2024 21:24:31 +1000 Subject: [PATCH] Fix incorrect load-time errors for non-hotkey lines containing '::' --- source/hotkey.cpp | 9 ++++++--- source/script.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/hotkey.cpp b/source/hotkey.cpp index 1f0af5253..31914d9f8 100644 --- a/source/hotkey.cpp +++ b/source/hotkey.cpp @@ -1833,10 +1833,13 @@ ResultType Hotkey::TextToKey(LPCTSTR aText, bool aIsModifier, Hotkey *aThisHotke else { // If there's something after the first word/character, it's not a hotkey. - if (aSyntaxCheckOnly) - return *keyname_end ? FAIL : OK; + // Only for *keyname_end != '\0', no error should be reported if aThisHotkey == NULL + // since the caller will attempt to parse the line as something else first, such as + // x := '::' if (*keyname_end) - return ValueError(ERR_INVALID_HOTKEY, aText, FAIL); + return aThisHotkey ? ValueError(ERR_INVALID_HOTKEY, aText, FAIL) : CONDITION_FALSE; + if (aSyntaxCheckOnly) + return OK; } HotkeyTypeType hotkey_type_temp; diff --git a/source/script.cpp b/source/script.cpp index c04a42782..95926a624 100644 --- a/source/script.cpp +++ b/source/script.cpp @@ -2843,7 +2843,7 @@ bool Script::IsSOLContExpr(LineBuffer &next_buf) // MsgBox // +!'::' ; 0 *hotkey_flag = '\0'; - bool valid_hotkey = Hotkey::TextInterpret(next_buf, NULL, true); + bool valid_hotkey = Hotkey::TextInterpret(next_buf, NULL, true) == OK; *hotkey_flag = *HOTKEY_FLAG; if (!valid_hotkey) return true; // It's not valid hotkey syntax, so treat it as continuation even if it's ultimately a syntax error.