From d71410dff52a0be1cd26d2129b909419cabe42b3 Mon Sep 17 00:00:00 2001 From: Henrixounez Date: Sun, 23 Jun 2019 14:13:32 +0200 Subject: [PATCH] REPL - Fix variable declare and not used by print by using an empty line to call the variables --- compiler/main.v | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/main.v b/compiler/main.v index 71bf18f00a..c4da8d397e 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -812,6 +812,8 @@ fn run_repl() []string { // so that it doesn't get called during the next print. if line.starts_with('print') { // TODO remove this once files without main compile correctly + void_line := line.substr(line.index('(') + 1, line.len - 1) + lines << void_line source_code := 'fn main(){' + lines.join('\n') + '\n' + line + '}' os.write_file(file, source_code) mut v := new_v( ['v', '-repl', file])