diff --git a/vlib/compiler/comptime.v b/vlib/compiler/comptime.v index 5484053097..709d9d0ae8 100644 --- a/vlib/compiler/comptime.v +++ b/vlib/compiler/comptime.v @@ -272,6 +272,9 @@ fn (p mut Parser) comptime_method_call(typ Type) { } fn (p mut Parser) gen_array_str(typ Type) { + if typ.has_method('str') { + return + } p.add_method(typ.name, Fn{ name: 'str' typ: 'string' diff --git a/vlib/compiler/fn.v b/vlib/compiler/fn.v index 3f546689ce..fa640ce797 100644 --- a/vlib/compiler/fn.v +++ b/vlib/compiler/fn.v @@ -888,7 +888,7 @@ fn (p mut Parser) fn_call_args(f mut Fn) { // Receiver is the first arg // Skip the receiver, because it was already generated in the expression if i == 0 && f.is_method { - if f.args.len > 1 && !p.is_js { + if f.args.len > 1 { // && !p.is_js { p.gen(',') } continue diff --git a/vlib/compiler/gen_js.v b/vlib/compiler/gen_js.v index 23c7e48545..9c3718f790 100644 --- a/vlib/compiler/gen_js.v +++ b/vlib/compiler/gen_js.v @@ -28,7 +28,8 @@ fn (p mut Parser) gen_fn_decl(f Fn, typ, _str_args string) { } name := p.table.fn_gen_name(f) if f.is_method { - p.genln('\n${f.receiver_typ}.prototype.${name} = function($str_args) {') + //p.genln('\n${f.receiver_typ}.prototype.${name} = function($str_args) {') + p.genln('function ${f.receiver_typ}_$name($str_args) {') } else { p.genln('/** @return { $typ } **/\nfunction $name($str_args) {') } @@ -100,7 +101,9 @@ fn (p mut Parser) gen_method_call(receiver &Var, receiver_type string, //mut cgen_name := p.table.fn_gen_name(f) //mut method_call := cgen_name + '(' - p.gen('.' + cgen_name.all_after('_') + '(') + //p.gen('/*2*/.' + cgen_name.all_after('_') + '(') + t := receiver_type.replace('*', '') + p.cgen.set_placeholder(method_ph, '${t}_$cgen_name(') //p.cgen.set_placeholder(method_ph, '$cast kKE $method_call') //return method_call }