AHK V2: Goto gives Error: Cannot jump from inside a function to outside

Discuss the future of the AutoHotkey language
SAbboushi
Posts: 142
Joined: 08 Dec 2014, 22:13

AHK V2: Goto gives Error: Cannot jump from inside a function to outside

18 Oct 2018, 23:09

Code: Select all

#SingleInstance
#Warn

goto S2
return

S2:
	SetTimer y:=displayMsg3(3333), -1

	displayMsg3(message)
	{
		local y
		y:= Func("displayMsg1") ; closure
		return y

		displayMsg1()
		{
			(message)
		}
	}
return
gives error:
Error: Cannot jump from inside a function to outside.

Line#
---> 004: Goto "S2"
005: Return
008: SetTimer(y:=displayMsg3(3333), -1)
011: {
013: y := Func("displayMsg1")
014: Return y
017: {
018: (message)

The program will exit.
No error if I comment out goto S2 (and Return) or use gosub

btw love the new dark theme on the forum :bravo:
User avatar
kczx3
Posts: 691
Joined: 06 Oct 2015, 21:39

Re: AHK V2: Goto gives Error: Cannot jump from inside a function to outside

19 Oct 2018, 08:11

Easy fix. Stop using Goto and Gosub. They are highly discouraged.
Helgef
Posts: 3300
Joined: 17 Jul 2016, 01:02
Contact:

Re: AHK V2: Goto gives Error: Cannot jump from inside a function to outside

19 Oct 2018, 11:47

Looks like a parsing error, I'm sure it will be fixed.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 5 guests