fix #2085
This commit is contained in:
parent
129cefd7e7
commit
5dc6eda5a6
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "6";
|
||||
public const string Build = "3";
|
||||
public const string Revision = "2527";
|
||||
public const string Revision = "2528";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=6
|
||||
%REVISION%=2527
|
||||
%COREVERSION%=3
|
||||
%REVISION%=2528
|
||||
%MINOR%=6
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.6.3.2527
|
||||
3.6.3.2528
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.6.3.2527'
|
||||
!define VERSION '3.6.3.2528'
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ namespace SyntaxVisitors
|
|||
|
||||
public override void visit(ident id)
|
||||
{
|
||||
// Это очень частный алгоритм переименования в мини-ПИ, но затрагивает он и лямбды. И механизм для этого - неадекватный
|
||||
// Надо исключать формальные параметры лямбд и одноимённые переменнные, определяемые у них внутри
|
||||
var newName = this.GetNewVariableName(id.name.ToLower());
|
||||
if (newName != null)
|
||||
{
|
||||
|
|
@ -212,6 +214,18 @@ namespace SyntaxVisitors
|
|||
ProcessNode(dn.right);
|
||||
}
|
||||
|
||||
public override void visit(function_lambda_definition fld)
|
||||
{
|
||||
BlockNamesStack.Add(new Dictionary<string, string>());
|
||||
var last = BlockNamesStack.Count - 1;
|
||||
for (var i=0; i< fld.parameters.expressions.Count; i++)
|
||||
{
|
||||
var qname = (fld.parameters.expressions[i] as ident).name.ToLower();
|
||||
BlockNamesStack[last][qname] = "-fl"; // -fl - формальный параметр лямбды - это стоп в поиске в GetNewVariableName
|
||||
}
|
||||
base.visit(fld);
|
||||
}
|
||||
|
||||
private string CreateNewVariableName(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
|
|
@ -233,6 +247,8 @@ namespace SyntaxVisitors
|
|||
{
|
||||
if (BlockNamesStack[i].ContainsKey(name))
|
||||
{
|
||||
if (BlockNamesStack[i][name] == "-fl") // формальный параметр лямбды - это стоп в поиске (переименовывать не надо!)
|
||||
return null;
|
||||
return BlockNamesStack[i][name];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
TestSuite/yield_lam_capt0.pas
Normal file
10
TestSuite/yield_lam_capt0.pas
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// #2085
|
||||
function f1: sequence of integer;
|
||||
begin
|
||||
var b: byte := 5;
|
||||
yield Arr(3).Select(b->b).First;
|
||||
end;
|
||||
|
||||
begin
|
||||
Assert(f1.First = 3);
|
||||
end.
|
||||
|
|
@ -2768,7 +2768,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
visit_program_code(_block.program_code);
|
||||
|
||||
// Очистили списки goto для меток перед следующим этапом - пока ничего не дало - закомментируем
|
||||
foreach (var l in context._cmn.labels)
|
||||
foreach (var l in context._cmn.labels)
|
||||
{
|
||||
l.goto_statements.Clear();
|
||||
l.comprehensive_code_block = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue