1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix memory bug with generic code generation

This commit is contained in:
Emily Hudson 2019-10-21 11:54:37 +01:00 committed by Alexander Medvednikov
parent dfc654f84e
commit a52cb315cb

View File

@ -674,23 +674,6 @@ fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type s
// p.cur_fn.called_fns << cgen_name
// }
$if windows { // TODO fix segfault caused by `dispatch_generic_fn_instance` on Windows
if f.is_generic {
p.check(.lpar)
mut b := 1
for b > 0 {
if p.tok == .rpar {
b -= 1
} else if p.tok == .lpar {
b += 1
}
p.next()
}
p.gen('/* SKIPPED */')
p.warn('skipped call to generic function `$f.name`\n\tReason: generic functions are currently broken on Windows 10\n')
return
}
}
// If we have a method placeholder,
// we need to preappend "method(receiver, ...)"
@ -1244,9 +1227,6 @@ fn (p mut Parser) register_multi_return_stuct(types []string) string {
}
fn (p mut Parser) dispatch_generic_fn_instance(f mut Fn, ti TypeInst) {
$if windows {
p.error('feature disabled on Windows')
}
mut new_inst := true
for e in f.type_inst {
if e.inst.str() == ti.inst.str() {
@ -1296,6 +1276,11 @@ fn (p mut Parser) dispatch_generic_fn_instance(f mut Fn, ti TypeInst) {
f.type_inst = []TypeInst
f.scope_level = 0
f.dispatch_of = ti
// TODO this is done to prevent a crash as a result of this not being
// properly initialised. This is a bug somewhere futher upstream
f.defer_text = []string {}
old_args := f.args
new_types := p.replace_type_params(f, ti)
f.args = []Var