Page 1 of 1

potential line continuation bug

Posted: 25 Jan 2019, 08:24
by vvhitevvizard
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.

Re: potential line continuation bug

Posted: 25 Feb 2019, 04:00
by _3D_
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!

Re: potential line continuation bug  Topic is solved

Posted: 22 Mar 2019, 05:07
by lexikos

Code: Select all

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