bug: closure doesn't recognize "base" keyword Topic is solved

Discuss the future of the AutoHotkey language
User avatar
vvhitevvizard
Posts: 299
Joined: 25 Nov 2018, 10:15
Location: Russia

bug: closure doesn't recognize "base" keyword

12 Jan 2019, 10:57

Code: Select all

class class1 extends class1.class2{
	method1(){
		msgbox("1|" base.__Class) ;ok
		closure1()

		closure1(){
			msgbox("2|" this.base.__Class) ;ok
			msgbox("3|" base.__Class) ;error
		}
	}
class class2{
}}
class1.method1()
keyword base works within methods and fails within closures. this, this.base, this.base.base, etc works as expected everywhere.
Helgef
Posts: 3721
Joined: 17 Jul 2016, 01:02
Contact:

Re: bug: closure doesn't recognize "base" keyword

12 Jan 2019, 11:40

It is only stated to work within methods, in the documentation.
User avatar
vvhitevvizard
Posts: 299
Joined: 25 Nov 2018, 10:15
Location: Russia

Re: bug: closure doesn't recognize "base" keyword

12 Jan 2019, 13:33

I see. At least its documented. :D
Btw, for class mreq extends req, calls base.Init() and this.base.Init() work different. Within req.Init(), this.__Class=mreq with 1st variant and this.__Class=req with 2nd one. Is it intended to be so?
Last edited by vvhitevvizard on 12 Jan 2019, 13:40, edited 1 time in total.
User avatar
vvhitevvizard
Posts: 299
Joined: 25 Nov 2018, 10:15
Location: Russia

Re: bug: closure doesn't recognize "base" keyword

12 Jan 2019, 13:39

Helgef, roger that! thank u for ur quick response =)
_3D_
Posts: 211
Joined: 29 Jan 2014, 14:40

Re: bug: closure doesn't recognize "base" keyword

25 Feb 2019, 06:21

As closure cant be member of a given class then base is not accessed inside closure without this.
In other words closure not "see" class members and to do this it need this.
AHKv2.0 use the future now.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 6 guests