Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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 mLipok, 12 years ago

I mean Expected.

comment:2 by jchd, 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 jchd, 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 guinness, 12 years ago

Resolution: No Bug
Status: newclosed

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

comment:5 by mLipok, 12 years ago

the bug was in reading HelpFile :(

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.