potential line continuation bug Topic is solved

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

potential line continuation bug

25 Jan 2019, 08:24

Speaking of if-statement and short-circuit alternatives, when I was creating some long expression, I accidentally found a new conundrum.
For the example, I simplified it to the smallest possible arrangement that keeps raising an error. The next syntax is correct at _load time_ (if statement's expression is split to 2 lines):

Code: Select all

	if(r:=DllCall(a, 'int',n 
		, 'ptr',p)) ;syntax accepted
		d++
		
And when I replace it with && expression:

Code: Select all

	(r:=DllCall(a, 'int',n
		, 'ptr',p))  ;error at load-time
		&& d++
It gives error: Missing ")"

if I join 2 lines in 1:

Code: Select all

	(r:=DllCall(a, 'int',n, 'ptr',p)) ;syntax accepted
		&& d++
		
the expression's syntax is accepted.
2nd line starting with , is correct itself (it is accepted in first variant with if statement). arrangement of parenthesis is not changed.
_3D_
Posts: 241
Joined: 29 Jan 2014, 14:40

Re: potential line continuation bug

25 Feb 2019, 04:00

I think there no any bug.
See syntax of IF in v2:

Code: Select all

If(condition) ;condition enclosed in brackets
	action ;next line is action
In your example:

Code: Select all

if(r:=DllCall(a, 'int',n 
		, 'ptr',p)) ;condition enclosed in brackets => r:=DllCall(a, 'int',n, 'ptr',p)
		d++	;action
Next when you add operator &&: then error is "Missing operand" - left && right - you missing left operand from action.
The right syntax:

Code: Select all

if((r:=DllCall(a, 'int',n 
		, 'ptr',p)) ;syntax accepted
		&& d++) ;condition enclosed in brackets => (r:=DllCall(a, 'int',n, 'ptr',p)) && d++
		action:= 1	;action
When brackets exist then condition become enclosed inside, next line is action.
Enjoy!
AHKv2.0 use the future now.
lexikos
Posts: 6668
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: potential line continuation bug  Topic is solved

22 Mar 2019, 05:07

Code: Select all

MsgBox "
(r:=DllCall(a, 'int',n  ; ← Continuation section with invalid options
    , 'ptr',p))  ; ← Body of continuation section
    && d++       ;
)"  ; ← Non-missing ")"

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 18 guests