fix memory bug with generic code generation
parent
dfc654f84e
commit
a52cb315cb
|
@ -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
|
// 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,
|
// If we have a method placeholder,
|
||||||
// we need to preappend "method(receiver, ...)"
|
// 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) {
|
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
|
mut new_inst := true
|
||||||
for e in f.type_inst {
|
for e in f.type_inst {
|
||||||
if e.inst.str() == ti.inst.str() {
|
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.type_inst = []TypeInst
|
||||||
f.scope_level = 0
|
f.scope_level = 0
|
||||||
f.dispatch_of = ti
|
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
|
old_args := f.args
|
||||||
new_types := p.replace_type_params(f, ti)
|
new_types := p.replace_type_params(f, ti)
|
||||||
f.args = []Var
|
f.args = []Var
|
||||||
|
|
Loading…
Reference in New Issue