BEGIN/END SEQUENCE causes compiler error XS0136

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Alf
Posts: 54
Joined: Wed Dec 30, 2020 10:04 am

BEGIN/END SEQUENCE causes compiler error XS0136

Post by Alf »

Hi to all,
after moving to 2.12.2.0 I get this compiler error:

Code: Select all

error XS0136: A local or parameter named 'Xs$Obj' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
The concerned code line contains: "BEGIN SEQUENCE". Sorry for my stupidity but I don't understand this error message. I guess there are some situations BEGIN/END SEQUENCE is not allowed? How can I solve this? By the way: Same code makes no trouble in earlier X#-Versions (and also not in VO)..
Alf
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BEGIN/END SEQUENCE causes compiler error XS0136

Post by robert »

Alf,
The XS$Obj variable is generated by the compiler for RECOVER statements.
DO you have a nested Begin sequence .. end ?
As always: example code helps a lot.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Alf
Posts: 54
Joined: Wed Dec 30, 2020 10:04 am

BEGIN/END SEQUENCE causes compiler error XS0136

Post by Alf »

Robert,
your guess is correct: Error XS0136 occurs here:

Code: Select all

BEGIN SEQUENCE
    // Some simple code
RECOVER
    BEGIN SEQUENCE ---> Error XS0136
    // some simple code
    END SEQUENCE
END SEQUENCE
Is this coding no longer allowed in 2.12.2.0?
Alf
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BEGIN/END SEQUENCE causes compiler error XS0136

Post by robert »

Alf,
It should be allowed, but is a bit unexpected.
The problem is that the compiler in the current build generates a temporary variable for both sequence blocks with the same name.
I'll change the compiler to make sure that no duplicate names are generated for the next build.
For now I would recommend to replace the inner begin sequence .. end sequence with a

Code: Select all

try 
.. your statements
catch 
   throw
end try
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Alf
Posts: 54
Joined: Wed Dec 30, 2020 10:04 am

BEGIN/END SEQUENCE causes compiler error XS0136

Post by Alf »

Hi Robert,
thanks for answer and advise.
Alf
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BEGIN/END SEQUENCE causes compiler error XS0136

Post by robert »

XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply