Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 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 Changed 9 years ago by mLipok

I mean Expected.

comment:2 Changed 9 years ago by jchd

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 Changed 9 years ago by jchd

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 Changed 9 years ago by guinness

  • Resolution set to No Bug
  • Status changed from new to 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

comment:5 Changed 9 years ago by mLipok

the bug was in reading HelpFile :(

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.