- I'd like to compile a custom version of AHK v2 that uses the old behaviour, i.e. compare anything that looks numeric, numerically, unless both items are forced as strings at the point where they are compared.
- This example demonstrates what changed:
Code: Select all
a := "1", b := "1.0"
MsgBox(a = b) ;0 (newer versions), 1 (older versions, preferable)
MsgBox(A_AhkVersion)
- Does anyone know where the changed code (re. comparison behaviour) is located in the source code?
- Or in which version it changed? (By testing available exes, I know that the newer behaviour was in force from at least v2.0-a038 onwards.)
- Some source code search terms: SYM_LTOE (less than or equal), this_infix_item.
- Perhaps it's the IsPureNumeric function, introduced in this commit:
Revised handling of types (integer/float/string). · Lexikos/AutoHotkey_L@275216e · GitHub
https://github.com/Lexikos/AutoHotkey_L/commit/275216e20724568ba7afbe6f2cc29297fd162be2
- [EDIT:] Here's a quick fix (although it goes too far, comparing forced strings that look numeric as numeric):
Code: Select all
;quick fix (script_expression.cpp):
;before:
if ( !(right_is_number && left_is_number) // i.e. they're not both numeric (or this is SYM_CONCAT).
|| IS_RELATIONAL_OPERATOR(this_token.symbol) && !right_is_pure_number && !left_is_pure_number ) // i.e. if both are strings, compare them alphabetically.
;after:
if ( !(right_is_number && left_is_number) // i.e. they're not both numeric (or this is SYM_CONCAT).
|| false) // i.e. if both are strings, compare them alphabetically.
- Now I need info re. AHK v1, how it detects operands that were forced as strings.