parser: fix register() bug in interfaces

pull/2790/head
Alexander Medvednikov 2019-11-20 18:19:13 +03:00
parent 28117353a9
commit 3e564a2506
2 changed files with 21 additions and 1 deletions

View File

@ -166,7 +166,7 @@ fn (p mut Parser) struct_decl() {
// }
// Check if reserved name
field_name_token_idx := p.cur_tok_index()
field_name := if name != 'Option' { p.table.var_cgen_name(p.check_name()) } else { p.check_name() }
field_name := if name != 'Option' && !is_interface { p.table.var_cgen_name(p.check_name()) } else { p.check_name() }
/*
if !p.first_pass() {
p.fgen(strings.repeat(` `, fmt_max_len - field_name.len))

View File

@ -53,3 +53,23 @@ fn test_perform_speak() {
}
interface Register {
register()
}
struct RegTest {a int}
fn (f RegTest) register() {
}
fn handle_reg(r Register) {
}
fn test_register() {
f := RegTest{}
f.register()
handle_reg(f)
}