[v2.1-alpha.12] Unknown class.

Report problems with documented functionality
User avatar
aseiot
Posts: 80
Joined: 05 Mar 2017, 04:25

[v2.1-alpha.12] Unknown class.

26 May 2024, 07:01

After switching to v2.1-alpha.12. It always complains "Unknown class", and I have narrow down the issue with following codes:

A.ahk

Code: Select all

msgbox a().test()


class A extends B{
	test()=>1
}

#Include C.ahk				; Comment this out, will ok
#Include B.ahk
B.ahk

Code: Select all

class B extends C{
    
}

#Include C.ahk
C.ahk

Code: Select all

class C extends D{

}

#include D.ahk
D.ahk

Code: Select all

class D{

}
This error message is
B.ahk (1) : ==> Unknown class.
Specifically: C
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.1-alpha.12] Unknown class.

30 May 2024, 21:48

#Include generally has no impact on anything. The demonstration is much clearer if you substitute the file contents for the directives (and omit the directive which is ignored because the file was already included).

Code: Select all

class A extends B{
	test()=>1
}

class C extends D{

}

class D{

}

class B extends C{
    
}
The bug occurs because at the time of each attempt to resolve extends C (first when class B is parsed and then again after reaching the end of the file), C exists but has no base (not even Class.Prototype) and therefore isn't considered to be a class. extends D would be resolved after that, if not for the error.

The method of resolving out-of-order class definitions had to be changed to support modules.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 9 guests