[SOLVED] AHK 1.1.33.02 triggers incorrect warnings

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

[SOLVED] AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 11:28

Upgraded from .32 to .33 and my .ahk file which includes #warn is raising numerous errors about subsequent code cannot be executed because of a previous return statement . . . . which is not true. Disabled #warn but unsure if it's a bug or it's a problem discovered by the updated interpreter. Info on the issue is most appreciated.
Last edited by ineuw on 05 Nov 2020, 15:07, edited 1 time in total.
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .
gregster
Posts: 9113
Joined: 30 Sep 2013, 06:48

Re: AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 11:32

It's warnings, not errors.

Yes, the new versions 1.1.33+ check for unreachable code (which was ignored before). So far, I haven't seen incorrect warnings from it.
Please show the code to reproduce it, if you think the warnings are wrong.

If you look at #warn, you can see that you can also selectively disable this new warn category: #Warn Unreachable, Off
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Re: AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 12:20

Much thanks for the reply. Of the 7 warnings, 4 were logical visible errors which I corrected. The rest could only be eliminated by #Warn Unreachable, Off While I don't see why the warnings are triggered, I am very interested in your assessment at a glance. Can I post a 1,300 line code here?
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .
gregster
Posts: 9113
Joined: 30 Sep 2013, 06:48

Re: AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 12:40

Better use ahkbin: https://p.ahkscript.org/ and post the link here.
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Re: AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 13:20

https://p.ahkscript.org/ didn't generate an unique url so I pasted it in pastebin. https://pastebin.com/c7zYqFSZ
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .
gregster
Posts: 9113
Joined: 30 Sep 2013, 06:48

Re: AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 13:33

I got three warnings:

Code: Select all

Warning:  This line will never execute, due to Return preceeding it.

	Line#
	950: Return
	950: SetKeyDelay,-1
	950: Send,{Blind}{? Up}
	950: Return
--->	951: AutoTrim,off
	952: selected = 
(shortened)
That's a valid warning, because you have a stray ? in there:

Code: Select all

#-::                           ?
autotrim, off
That makes it an unintentional one-line remapping, and autotrim, off (and following lines) unreachable.

And

Code: Select all

Warning:  This line will never execute, due to Return preceeding it.

	Line#
	1283: clipboard = 
	1284: SendInput,{text}{{Do not move to Commons}}
	1285: Return
--->	1295: DetectHiddenText,on
	1296: Send,{lshift down}{lbutton}{lshift up}
	1296: Return
(shortened)
That is correct, detecthiddentext, on is unreachable code (the directive #ifwinactive has no effect on this line, it gets evaluated already at script start and only affects hotkeys/-strings, not a single line like this:

Code: Select all

return

; win+x                         WINDOWS MENU WHEN WINDOWS SHORTCUTS ARE ENABLED. Disabled through Ultimate Windows Tweaks - Disable Winkey shortcuts

; win+z                         UNASSIGNED

;;; mouse

; mbutton
#ifwinactive ahk_exe vivaldi.exe
detecthiddentext, on
mbutton::send, {lshift down}{lbutton}{lshift up}
Effectively (looking at code that is relevant for it), there is a return immediately above it.

Something similar is true for

Code: Select all

mbutton::send, {lshift down}{lbutton}{lshift up}
detecthiddentext, off
the one-line hotkey above it makes detecthiddentext, off unreachable (that hotkey has an implicit return).

#Warn works correctly, afaics.
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Re: AHK 1.1.33.02 triggers incorrect warnings

05 Nov 2020, 15:07

Again, much thanks for taking the time to check it. I got the identical results. I'll close the topic as solved.
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Hugh Jars, peter_ahk, Pianist and 342 guests