From 8ecd62e56f6afdaf993eea3ae48307da490c3cff Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 2 Aug 2019 05:20:18 +0200 Subject: [PATCH] comptime: fix app.$action() or {} --- compiler/comptime.v | 5 ++++- compiler/parser.v | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/comptime.v b/compiler/comptime.v index edcad2f035..af2a0d3610 100644 --- a/compiler/comptime.v +++ b/compiler/comptime.v @@ -197,12 +197,15 @@ fn (p mut Parser) comptime_method_call(typ Type) { p.cgen.cur_line = '' p.check(.dollar) var := p.check_name() - for method in typ.methods { + for i, method in typ.methods { if method.typ != 'void' { continue } receiver := method.args[0] amp := if receiver.is_mut { '&' } else { '' } + if i > 0 { + p.gen(' else ') + } p.gen('if ( string_eq($var, _STR("$method.name")) ) ${typ.name}_$method.name($amp $p.expr_var.name);') } p.check(.lpar) diff --git a/compiler/parser.v b/compiler/parser.v index 0ba0ec21a6..1e9cb87bf7 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1016,7 +1016,7 @@ fn (p mut Parser) close_scope() { // Move back `var_idx` (pointer to the end of the array) till we reach the previous scope level. // This effectivly deletes (closes) current scope. mut i := p.cur_fn.var_idx - 1 - for; i >= 0; i-- { + for ; i >= 0; i-- { v := p.cur_fn.local_vars[i] if v.scope_level != p.cur_fn.scope_level { // println('breaking. "$v.name" v.scope_level=$v.scope_level') @@ -1030,7 +1030,7 @@ fn (p mut Parser) close_scope() { p.genln('v_string_free($v.name); // close_scope free') } else if v.ptr { - p.genln('free($v.name); // close_scope free') + //p.genln('free($v.name); // close_scope free') } }