table: interface cast fix

pull/4662/head
Alexander Medvednikov 2020-04-25 09:18:10 +02:00
parent 9229a963ed
commit d54b48b300
3 changed files with 2 additions and 13 deletions

View File

@ -27,17 +27,6 @@ fn __new_array(mylen int, cap int, elm_size int) array {
} }
return arr return arr
} }
fn new_array(mylen int, cap int, elm_size int) array {
cap_ := if cap == 0 { 1 } else { cap }
arr := array{
len: mylen
cap: cap_
element_size: elm_size
data: vcalloc(cap_ * elm_size)
}
return arr
}
// TODO // TODO
pub fn make(len int, cap int, elm_size int) array { pub fn make(len int, cap int, elm_size int) array {

View File

@ -237,7 +237,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
foo: 'foo' foo: 'foo'
} }
} }
typ := p.table.register_type_symbol(t) typ := table.new_type(p.table.register_type_symbol(t))
ts := p.table.get_type_symbol(typ) // TODO t vs ts ts := p.table.get_type_symbol(typ) // TODO t vs ts
// Parse methods // Parse methods
mut methods := []ast.FnDecl mut methods := []ast.FnDecl

View File

@ -485,7 +485,7 @@ pub fn (t &Table) check(got, expected Type) bool {
exp_type_sym := t.get_type_symbol(expected) exp_type_sym := t.get_type_symbol(expected)
// //
if exp_type_sym.kind == .interface_ { if exp_type_sym.kind == .interface_ {
info := got_type_sym.info as Interface info := exp_type_sym.info as Interface
println('gen_types before') println('gen_types before')
println(info.gen_types) println(info.gen_types)
info.gen_types << got_type_sym.name info.gen_types << got_type_sym.name