[ManiaScript] declare-as-for fails under some conditions

Moderator: NADEO

Locked
User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

[ManiaScript] declare-as-for fails under some conditions

Post by m4rcel »

I found a small bug regarding the scope of variables: Under some conditions, the "declare as for" construct fails, although there should be no conflict with existing variables.

The following code blocks assumes that Object1 and Object2 are valid objects, e.g. CMlControls.

Code: Select all

// Variable name conflicts can be resolved using the optional "as" in the declare for. So this is working fine:
declare Integer Color as Color1 for Object1;
declare Integer Color as Color2 for Object2;
Color2 = Color1;

Code: Select all

// You can also define "Color" afterwards, still compiles.
declare Integer Color as Color1 for Object1;
declare Integer Color as Color2 for Object2;
declare Integer Color;
Color2 = Color1;

Code: Select all

// Yet if you define "Color" before, compilation fails 
declare Integer Color;
declare Integer Color as Color1 for Object1; // Compilation error: "The variable Color has already been declared in the same bloc."
declare Integer Color as Color2 for Object2;
Color2 = Color1;
The third code block fails to compile, because he says "Color" is already defined. Yet I don't see any conflict, because neither of the declare-for is trying to use "Color" in the current scope (as also shown in the second code block, which compiles fine).

I hope it is clear what I want to say, I don't know how to describe it better ^^


[Bug found in Build 27/12/12 19:36, but if I remember right, I already came across it before Beta2, but did not analyzed it any further.]
ImageImage
Image
Locked

Return to “Maniaplanet Reports”

Who is online

Users browsing this forum: No registered users and 1 guest