Continuation section & reserved words error priority

Discuss the future of the AutoHotkey language
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Continuation section & reserved words error priority

07 Apr 2018, 16:17

Using reserved name elements, such as Break/While and likely others, within unclosed continuation section throws improper error message:

Code: Select all

MsgBox(
	break
The following reserved word must not be used as a variable name:
"break"
Instead of:

Code: Select all

MsgBox(
	asd
Error: Missing ")"
This got me confused earlier today, as unclosed function call detected 2 various breaks within the script, getting me into thinking the break is broken.

Tested with v2.0a-093, error also happened on 082.



Ps. Any chance to make Allman's coding style work for array variable assigment?

Following doesn't work:

Code: Select all

test_var :=
{
	"x": 123
}
Line Text: test_var
Error: ":=" requires at least 2 parameters.
But this does:

Code: Select all

test_var := {
	"x": 123
}
Function call counterpart works, due to use of ():

Code: Select all

MsgBox
(
	"test"
)
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Continuation section & reserved words error priority

07 Apr 2018, 20:10

Both error messages are proper. The program can only understand your intention if you express it clearly, using the correct syntax. If some symbols are missing, the program has no way to determine where you intended to place them. If it considers things in linear order, it will see the invalid "break" before it can be determined that the ")" is missing (i.e. when it has reached the end of the file and not found one).

However, I agree that 'Missing ")"' would be more helpful in this case, and it can be done.

A function call statement with continuation section is not equivalent to a function call with parentheses. Consider this:

Code: Select all

MsgBox
(
	"test"
) = "OK" ? MsgBox("OK") : MsgBox("Not OK")

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 8 guests