fix #1985
This commit is contained in:
parent
fe19dfabee
commit
75ef577703
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "5";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "2134";
|
||||
public const string Revision = "2135";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=2134
|
||||
%MINOR%=5
|
||||
%REVISION%=2135
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.5.0.2134'
|
||||
!define VERSION '3.5.0.2135'
|
||||
|
|
|
|||
|
|
@ -30,7 +30,38 @@ namespace SyntaxVisitors
|
|||
{
|
||||
if (node is T)
|
||||
foundT = true;
|
||||
else
|
||||
else
|
||||
base.DefaultVisit(node);
|
||||
}
|
||||
}
|
||||
public class HasStatementWithBarrierVisitor<T,Barrier> : BaseEnterExitVisitor
|
||||
where T : statement
|
||||
where Barrier: syntax_tree_node
|
||||
{
|
||||
private bool foundT = false;
|
||||
|
||||
public static bool Has(syntax_tree_node node)
|
||||
{
|
||||
HasStatementWithBarrierVisitor<T, Barrier> vis = new HasStatementWithBarrierVisitor<T, Barrier>();
|
||||
|
||||
vis.ProcessNode(node);
|
||||
|
||||
return vis.foundT;
|
||||
}
|
||||
|
||||
public override void Enter(syntax_tree_node sn) // Искать всюду, но не заходить в узлы Barrier и вложенные
|
||||
{
|
||||
if (sn is Barrier)
|
||||
{
|
||||
visitNode = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DefaultVisit(syntax_tree_node node)
|
||||
{
|
||||
if (node is T)
|
||||
foundT = true;
|
||||
else
|
||||
base.DefaultVisit(node);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,12 +100,14 @@ namespace SyntaxVisitors
|
|||
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_NESTED_SUBROUTINES", pd.source_context);
|
||||
}
|
||||
|
||||
if (pd.has_yield && pd.DescendantNodes().OfType<try_stmt>().Count() > 0)
|
||||
if (pd.has_yield && HasStatementWithBarrierVisitor<try_stmt,function_lambda_definition>.Has(pd))
|
||||
//pd.DescendantNodes().OfType<try_stmt>().Count() > 0)
|
||||
{
|
||||
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_TRY_EXCEPT_FINALLY", pd.source_context);
|
||||
}
|
||||
|
||||
if (pd.has_yield && pd.DescendantNodes().OfType<lock_stmt>().Count() > 0)
|
||||
if (pd.has_yield && HasStatementWithBarrierVisitor<lock_stmt,function_lambda_definition>.Has(pd))
|
||||
//pd.DescendantNodes().OfType<lock_stmt>().Count() > 0)
|
||||
{
|
||||
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_LOCK", pd.source_context);
|
||||
}
|
||||
|
|
|
|||
16
TestSuite/lock_in_lambda_in_yield.pas
Normal file
16
TestSuite/lock_in_lambda_in_yield.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function f1: sequence of byte; //Ошибка: Функции с yield не могут содержать блоков try..except и try..finally
|
||||
begin
|
||||
yield 0;
|
||||
|
||||
var p: procedure := ()->
|
||||
begin
|
||||
lock(new object) do
|
||||
begin
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
||||
15
TestSuite/try_in_lambda_in_yield.pas
Normal file
15
TestSuite/try_in_lambda_in_yield.pas
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function f1: sequence of byte; //Ошибка: Функции с yield не могут содержать блоков try..except и try..finally
|
||||
begin
|
||||
yield 0;
|
||||
|
||||
var p: procedure := ()->
|
||||
begin
|
||||
try
|
||||
except
|
||||
end
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
||||
Loading…
Reference in a new issue