Possible Bug: object with numeric key in v2.0-a095-9f724c5 Topic is solved

Discuss the future of the AutoHotkey language
User avatar
aseiot
Posts: 11
Joined: 05 Mar 2017, 04:25

Possible Bug: object with numeric key in v2.0-a095-9f724c5

29 Apr 2018, 07:07

Code: [Select all] [Download] GeSHi © Codebox Plus

F := {"-2146826281" : "ANYTHING"}
MsgBox F["-2146826281"] ; SHOW EMPTY STRING
MsgBox F[-2146826281] ; Cause AHK CRASH
User avatar
aseiot
Posts: 11
Joined: 05 Mar 2017, 04:25

Re: Possible Bug: object with numeric key in v2.0-a095-9f724c5

02 May 2018, 00:43

Did more test about the numeric key of object.
v2-changes wrote:Integer constants and numeric strings outside of the supported range (of 64-bit signed integers) now overflow/wrap around, instead of being capped at the min/max value. This is consistent with math operators, so 9223372036854775807+1 == 9223372036854775808 (but both produce -9223372036854775808).

And I found some inconsistent results:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



So I anticipate the O["9223372036854775808"] do not auto convert to O[9223372036854775808], so treated it as string key?

Another test:

Code: [Select all] [Download] GeSHi © Codebox Plus

O := {}
O[100] := "ANYTHING"
MsgBox O[100] ; "ANYTHING"
MsgBox O["100"] ; "ANYTHING"


"100" is converted to 100? I got an explanation in v2-changes

v2-changes wrote:As of v2.0-a067, numeric strings are converted to pure integers where possible without causing the kind of data loss described above.


Back to my preview problem:

Code: [Select all] [Download] GeSHi © Codebox Plus

; Crashed sometimes with Exit code: 3221225477. 

F := {"-2146826281" : "ANYTHING"}
MsgBox F["-2146826281"] ; SHOW EMPTY STRING
MsgBox F[-2146826281] ; SHOW EMPTY STRING

for k, v in F
MsgBox k "," v ; "-2146826281,ANYTHING" as expected.


So, above all, my question is the correct ways to set and get the key and value consistently in object?
User avatar
nnnik
Posts: 2905
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Possible Bug: object with numeric key in v2.0-a095-9f724c5

02 May 2018, 00:51

Yes it is - this might relate to a recent change in the AutoHotkey source.
I'm sure someone will look into it in time.
Recommends AHK Studio

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 2 guests