Modify ↓
#2763 closed Bug (No Bug)
IsDeclared - Return Value BUG
| Reported by: | mLipok | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.12.0 | Severity: | None |
| Keywords: | Cc: |
Description
Global $_i = 1 MsgBox(1, 'Global', IsDeclared($_i)) Test() Func Test() Local $i = 1 MsgBox(1, 'Local', IsDeclared($i)) EndFunc ;==>Test
Expeced 1 and -1
Attachments (0)
Change History (5)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
The bug is not where you think it is. Check IsDeclared help page:
Global $_i = 1
MsgBox(1, 'Global', IsDeclared("_i"))
Test()
Func Test()
Local $i = 1
MsgBox(1, 'Local', IsDeclared("i"))
EndFunc ;==>Test
The actual bug is that both calls should return 0 in your posted code.
IsDeclared($_i) --> IsDeclared(1) --> IsDeclared("1") cast since IsDeclared expects a string argument --> 0 since no variable $1 exist.
comment:3 by , 12 years ago
BTW the latest release (v3.3.12.0) actually returns 0 twice.
I'd to classify as "No bug" if I could login here.
comment:4 by , 12 years ago
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
As jchd rightly said this isn't a bug, as a IsDeclared() requires a "string representation" of the variable name.
Global $_i = '_i' ConsoleWrite(IsDeclared($_i) & @CRLF) Test() Func Test() Local $i = 'i' ConsoleWrite(IsDeclared($i) & @CRLF) EndFunc ;==>Test
Note:
See TracTickets
for help on using tickets.

I mean Expected.