[a135] Possible bug with line continuation and ternary operators Topic is solved

Report problems with documented functionality
OpalMonkey
Posts: 18
Joined: 23 Jan 2014, 03:02

[a135] Possible bug with line continuation and ternary operators

22 May 2021, 01:18

Just tried moving to a135 (from a134) and the only thing that needed changing was where I was splitting ternary operators over multiple lines, like so:

Code: Select all

Test1(value) {
	Return value
		? True
		: False
}
Every other combination of this I try seems to work, which is what's making me think it's a bug. All of these (and more) work fine:

Code: Select all

Test2(value) {
	Return value ? True
		: False
}
Test3(value) {
	Return value
		? True : False
}
Test4(value) {
	Return (value
		? True
		: False)
}
Maybe it's an intended consequence of the changes to line continuation operators, but found it odd and thought I'd report it, just in case. Using parentheses as in Test4 is an easy workaround.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: [a135] Possible bug with line continuation and ternary operators

22 May 2021, 02:33

Apparently I didn't test it with more than one consecutive line continuation (without enclosure or a continuation section). :oops:

Code: Select all

while (balance > 0 && next_buf_length != -1);
should now be

Code: Select all

while (balance >= 0 && next_buf_length != -1);
(balance > 0 represents an unclosed (/[/{, and balance < 0 represents an error, such as an unclosed quote.)
OpalMonkey
Posts: 18
Joined: 23 Jan 2014, 03:02

Re: [a135] Possible bug with line continuation and ternary operators

22 May 2021, 03:07

@lexikos
Just glad to help by catching a bug, and nice that it isn't difficult to work around till the next release. Though I did just realize that this affects all line continuations, I just haven't had the same need of multiple line continuations much in v2.

Thanks for the explanation, too. I very much appreciate not only your work on AHK (and have been enjoying v2 immensely, now that I'm making the switch) but how transparent you are regarding your thoughts on things lately and how much information you give when issues arise. I've learned some interesting stuff reading your recent explanations about bugs and issues people have had.
User avatar
vvhitevvizard
Posts: 454
Joined: 25 Nov 2018, 10:15
Location: Russia

Re: [a135] Possible bug with line continuation and ternary operators

22 May 2021, 04:22

a134->a135: More examples with that multiple line continuation issue:

Code: Select all

class gfx{ ;gfx obj with doublebuffering
	static AlphaBlend:=1 ;0=gp_bitblt, 1=gp_alphablend
		, Mode:=0 ;0=bm+setimage (REQ: "BackgroundTrans 0xE"), 1=dib+bitblt  (115mcs vs 70mcs), 2=LayeredWindow
		, Smoothing:=4 ;anti-alias mode
}
error at line 4: not a valid method, class or property definition

example 2:

Code: Select all

loop(_n)
	b:=_b+(i:=a_index-1), (i&0xF) || (s.=(i ? "`n":"") format("{:X}", b) ": ", a:="")
	, (_u) ? ((i&1) || a.=strget(b,1,'UTF-16')) : a.=((c:=numget(b,'uchar'))<0x20 || c>0x7E) ? ".":chr(c)
	, (i&m[_t]) || s.=format(f, numget(_b+i,t[_t])) " "
error at line 4: function call require a space or "("
I'm glad to see the bug is confirmed so soon and the workaround is ready for the next update :)

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 58 guests