bug fix #439
This commit is contained in:
parent
145f9aeb21
commit
c67922ebc3
|
|
@ -38,7 +38,7 @@ namespace SyntaxVisitors
|
|||
VarIdent.source_context = yn.ex.source_context;
|
||||
var_statement vs;
|
||||
if (yn.ex is nil_const)
|
||||
vs = new var_statement(VarIdent, new named_type_reference("System.Object"), yn.ex);
|
||||
vs = new var_statement(VarIdent, new named_type_reference("$yield_element_type"), yn.ex);
|
||||
else
|
||||
vs = new var_statement(VarIdent, yn.ex);
|
||||
vs.source_context = yn.ex.source_context;
|
||||
|
|
|
|||
8
TestSuite/yield3.pas
Normal file
8
TestSuite/yield3.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
function Test: sequence of integer->integer;
|
||||
begin
|
||||
yield nil;
|
||||
end;
|
||||
|
||||
begin
|
||||
assert(Test.First = nil);
|
||||
end.
|
||||
|
|
@ -2092,6 +2092,20 @@ namespace PascalABCCompiler.TreeConverter
|
|||
public SymbolInfoList find(string name)
|
||||
{
|
||||
SymbolTable.Scope curscope = CurrentScope;
|
||||
if (name == "$yield_element_type")
|
||||
{
|
||||
if (top_function != null)
|
||||
{
|
||||
return new SymbolInfoList(new SymbolInfoUnit(top_function.return_value_type.instance_params[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
type_node tn = converted_type.ImplementingInterfaces.Find(x=>(x as type_node).full_name.StartsWith("System.Collections.Generic.IEnumerable")) as type_node;
|
||||
return new SymbolInfoList(new SymbolInfoUnit(tn.instance_params[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SymbolInfoList si = curscope.Find(name, curscope);
|
||||
if (si == null && _compiled_tn != null && curscope.TopScope != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1613,6 +1613,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
names.names[names.names.Count-1].name += "Attribute";
|
||||
si = context.find_definition_node(names, loc);
|
||||
}
|
||||
|
||||
if (si != null && si.First().sym_info != null && si.First().sym_info.general_node_type == general_node_type.generic_indicator)
|
||||
{
|
||||
generic_indicator gi = si.First().sym_info as generic_indicator;
|
||||
|
|
@ -15466,7 +15467,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
private expression_node ident_value_reciving(SyntaxTree.ident _ident)
|
||||
{
|
||||
SymbolInfoList si = context.find(_ident.name);
|
||||
SymbolInfoList si = context.find(_ident.name);
|
||||
return ident_value_reciving(si, _ident);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue