V2 Unexpected Reserve Word Error after improper blank variable declaration Topic is solved

Report problems with documented functionality
fatodubs
Posts: 29
Joined: 20 Sep 2017, 18:53

V2 Unexpected Reserve Word Error after improper blank variable declaration

Post by fatodubs » 26 Jan 2023, 12:20

I'm converting code to V2, and ran into this error, which confounded me for a few minutes.

Code: Select all

FunctionName(params*) {
	strRet:=
	For k,v in params
		strWrite.=v
}
The error is:

Code: Select all

Error: Unexpected reserved word.

Text:	in params
Line:	15
File:	T:\Security\AHK Scripts\Test2.ahk
The issue is actually the line before it. After I changed it to strRet:="", the error was resolved.

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: V2 Unexpected Reserve Word Error after improper blank variable declaration

Post by lexikos » 15 Feb 2023, 01:53

This is by design. In v2, any line ending with an operator is merged with the following line, so the overall expression is strRet:= For k,v in params. When lines are merged, the line number in the error report is always of the first line.

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: V2 Unexpected Reserve Word Error after improper blank variable declaration  Topic is solved

Post by lexikos » 19 Jun 2023, 06:02

v2.0.3 gives a different error message, by avoiding line continuation when the next line starts with the name of a control flow statement.

Post Reply

Return to “Bug Reports”