From 5ff69c68b7fbdf38ad1918fb0f402f497b594d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Fri, 27 May 2016 09:04:22 +0200 Subject: [PATCH] bug fix #166 --- CodeCompletion/DomSyntaxTreeVisitor.cs | 31 +++++++++++++++++++++++++- TestSuite/short_fun.pas | 4 ++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 882f79640..4164b0c33 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -1475,7 +1475,36 @@ namespace CodeCompletion is_proc_realization = false; if (_procedure_definition.proc_body != null) { - cur_scope = returned_scope; + if (_procedure_definition.proc_header is function_header && (_procedure_definition.proc_header as function_header).return_type == null) + { + var fh = (_procedure_definition.proc_header as function_header); + if (fh != null && fh.return_type == null) + { + var bl = _procedure_definition.proc_body as block; + if (bl != null && bl.program_code != null) + { + if (bl.program_code.subnodes.Count == 1) + { + var ass = bl.program_code.subnodes[0] as assign; + if (ass != null && ass.to is ident && (ass.to as ident).name.ToLower() == "result") + { + if (!(ass.from is nil_const)) + { + ProcScope tmp_scope = returned_scope as ProcScope; + ass.from.visit(this); + if (returned_scope != null && returned_scope is TypeScope) + { + tmp_scope.return_type = returned_scope as TypeScope; + tmp_scope.Complete(); + returned_scope = tmp_scope; + } + } + } + } + } + } + } + cur_scope = returned_scope; /*if ((ret_tn as ProcScope).return_type != null) { ret_tn.AddName("Result",new ElementScope(new SymInfo("Result", SymbolKind.Variable,"Result"),(ret_tn as ProcScope).return_type,cur_scope)); diff --git a/TestSuite/short_fun.pas b/TestSuite/short_fun.pas index 32b9c5c05..e79b0e7b6 100644 --- a/TestSuite/short_fun.pas +++ b/TestSuite/short_fun.pas @@ -11,9 +11,9 @@ end ; begin var a1 := new A; - write(a1.f); + assert(a1.f=2); a1.p; write(3); - write(f); + assert(f=4); p; end. \ No newline at end of file