From f1373874efbbe69ce0cc60e531505573f21c266c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 29 Jul 2019 17:35:56 +0300 Subject: [PATCH] compiler: fix issue #1350 - an error is produced, when a void fn returns a value --- compiler/modules.v | 2 +- compiler/parser.v | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/modules.v b/compiler/modules.v index 02d8032bdb..748a1acaac 100644 --- a/compiler/modules.v +++ b/compiler/modules.v @@ -135,7 +135,7 @@ pub fn(graph &ModDepGraph) imports() []string { return mods } -pub fn(graph &ModDepGraph) last_node() { +pub fn(graph &ModDepGraph) last_node() ModDepGraphNode { return graph.nodes[graph.nodes.len-1] } diff --git a/compiler/parser.v b/compiler/parser.v index fb6ddca11d..0da6048e91 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -3331,8 +3331,8 @@ fn (p mut Parser) return_st() { } else { // Don't allow `return val` in functions that don't return anything - if false && p.tok == .name || p.tok == .number { - p.error('function `$p.cur_fn.name` does not return a value') + if p.tok == .name || p.tok == .number || p.tok == .str { + p.error('function `$p.cur_fn.name` should not return a value') } if p.cur_fn.name == 'main' {