Opened on Mar 17, 2023 at 1:48:23 AM
Last modified on Feb 27, 2024 at 7:31:36 AM
#3948 assigned Bug
Map object: keys [0] and ["["] clash
| Reported by: | Owned by: | Jon | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.16.1 | Severity: | None |
| Keywords: | maps, keys | Cc: |
Description
Hi team,
I realise that map objects are experimental and bug reports are not wanted, but I just thought I'd record this here in case anyone is interested.
When a map object contains a key of 0 and a key of [ these seem to clash in some way and tend to overwrite each other. But somewhat intermittently.
Here's an example script:
Local $map[] $map["a"] = 1 $map["0"] = 2 $map[0] = 3 $map["["] = 4 ConsoleWrite($map["a"] & @CRLF) ; expecting 1 ConsoleWrite($map["0"] & @CRLF) ; expecting 2 ConsoleWrite($map[0] & @CRLF) ; expecting 3, but sometimes prints 4 ConsoleWrite($map["["] & @CRLF) ; expecting 4 $map[0] = 5 ConsoleWrite($map[0] & @CRLF) ; expecting 5 ConsoleWrite($map["["] & @CRLF) ; expecting 4, but sometimes prints 5
When running this script, I would expect the console to show:
1 2 3 4 5 4
This happens intermittently, on about 40% of executions. On the other 60%, I get this result instead, where any assignment to $map[0] and $map["["] ends up overwriting each other:
1 2 4 4 5 5
I suspect that somehow, internally, 0 and [ are assigned the same value, resulting in the clash.
I uncovered this while trying to create a map of various characters and their binary representations. One workaround is to ensure the keys are all strings, and not use integer keys. It was a confusing bug for a while, though.
Attachments (0)
Change History (2)
comment:1 by , on Feb 20, 2024 at 3:57:05 PM
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , on Feb 27, 2024 at 7:31:36 AM
| Owner: | changed from to |
|---|

Fix sent to Jon