cgen: add `new` to reserved words

pull/4733/head
Alexander Medvednikov 2020-05-05 16:50:59 +02:00
parent ddb5a8e6e4
commit ff88906e9a
1 changed files with 4 additions and 5 deletions

View File

@ -36,7 +36,8 @@ const (
'unsigned', 'unsigned',
'void', 'void',
'volatile', 'volatile',
'while' 'while',
'new'
] ]
) )
@ -359,7 +360,7 @@ typedef struct {
info := typ.info as table.FnType info := typ.info as table.FnType
func := info.func func := info.func
sym := g.table.get_type_symbol(func.return_type) sym := g.table.get_type_symbol(func.return_type)
is_multi := sym.kind == .multi_return is_multi := sym.kind == .multi_return
is_fn_sig := func.name == '' is_fn_sig := func.name == ''
if !info.has_decl && (!info.is_anon || is_fn_sig) && !is_multi { if !info.has_decl && (!info.is_anon || is_fn_sig) && !is_multi {
fn_name := if func.is_c { fn_name := if func.is_c {
@ -1926,11 +1927,9 @@ fn (mut g Gen) return_statement(node ast.Return) {
return return
} }
fn_return_is_optional := g.fn_decl.return_type.flag_is(.optional) fn_return_is_optional := g.fn_decl.return_type.flag_is(.optional)
// got to do a correct check for multireturn // got to do a correct check for multireturn
sym := g.table.get_type_symbol(g.fn_decl.return_type) sym := g.table.get_type_symbol(g.fn_decl.return_type)
fn_return_is_multi := sym.kind == .multi_return fn_return_is_multi := sym.kind == .multi_return
// optional multi not supported // optional multi not supported
if fn_return_is_multi && !fn_return_is_optional { if fn_return_is_multi && !fn_return_is_optional {
g.write(' ') g.write(' ')