Page 1 of 1

[FIXED] Syntax error with scoped statements

Posted: 17 Feb 2018, 13:20
by zocka

Code: Select all

main() {
	{+++code+++}
	log("test");
}
throws
syntax error, unexpected MANIASCRIPT_BRACKET_CURLY_OP

Putting a statement above (like move the log a line up) works. Without the braces it of course works as well.
(It occured to me with labels but holds true for any code block)
It happens with the scoped statement ("{"+StatementList+"}") as first statement in any kind of statement list, e.g. function bodies or other scoped statements.
That was a lot of statements o_o

greetz

Re: Syntax error with scoped statements

Posted: 17 Feb 2018, 14:45
by Dommy
I think I ran into similar issue, which could be solved by formatting the scoped label differently:

Code: Select all

{ +++MyLabel+++ }
or

Code: Select all

{
	+++MyLabel+++
}
Indeed

Re: Syntax error with scoped statements

Posted: 17 Feb 2018, 18:48
by zocka
no, that doesn't work like in this example:

Code: Select all

***init***
***
log("init");
***

Void test() {
	log("testfn");
	{
		{
		^-- unexpected MANIASCRIPT_BRACKET_CURLY_OP
			declare Foo = 3;
		}
		declare Bar = 4;
	}
}

main() {
	test();
	log("test");
}

Re: Syntax error with scoped statements

Posted: 17 Feb 2018, 20:21
by Miss
Wow, Maniascript doesn't do regular scopes?

Re: Syntax error with scoped statements

Posted: 17 Feb 2018, 20:24
by zocka
It does, but just not as first statement in a block.

Re: Syntax error with scoped statements

Posted: 17 Feb 2018, 20:25
by Miss
Wow :P

[fixed] Syntax error with scoped statements

Posted: 27 Jan 2020, 14:33
by reaby
As of maniaplanet 4.1 this seems to be fixed.

Code: Select all

***code***
*** 
{
	log("works!");
}
***

main() {
	{+++code+++}
	log("works");
}

some admin could perhaps add fixed tag to the original topic ?

Re: [FIXED] Syntax error with scoped statements

Posted: 27 Jan 2020, 16:51
by Miss
Done :thumbsup:

Thanks for checking!