parser: small c2v fixes

pull/8729/head
Alexander Medvednikov 2021-02-12 09:12:22 +01:00
parent 67c6f24c84
commit 0a03856c83
4 changed files with 5 additions and 4 deletions

View File

@ -1878,7 +1878,7 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type {
// builtin C.m*, C.s* only - temp // builtin C.m*, C.s* only - temp
c.warn('function `$f.name` must be called from an `unsafe` block', call_expr.pos) c.warn('function `$f.name` must be called from an `unsafe` block', call_expr.pos)
} }
if f.mod != 'builtin' && f.language == .v && f.no_body { if f.mod != 'builtin' && f.language == .v && f.no_body && !c.pref.translated {
c.error('cannot call a function that does not have a body', call_expr.pos) c.error('cannot call a function that does not have a body', call_expr.pos)
} }
for generic_type in call_expr.generic_types { for generic_type in call_expr.generic_types {

View File

@ -80,7 +80,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
first_pos.extend(last_pos)) first_pos.extend(last_pos))
} }
} else { } else {
if p.tok.kind == .not && p.tok.line_nr == p.prev_tok.line_nr { if p.tok.kind == .not { // && p.tok.line_nr == p.prev_tok.line_nr {
last_pos = p.tok.position() last_pos = p.tok.position()
is_fixed = true is_fixed = true
has_val = true has_val = true

View File

@ -1015,7 +1015,8 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
} }
if p.tok.kind in [.assign, .decl_assign] || p.tok.kind.is_assign() { if p.tok.kind in [.assign, .decl_assign] || p.tok.kind.is_assign() {
return p.partial_assign_stmt(left, left_comments) return p.partial_assign_stmt(left, left_comments)
} else if tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] } else if !p.pref.translated // TODO remove translated
&& tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select]
&& left0 !is ast.CallExpr && (is_top_level || p.tok.kind != .rcbr) && left0 !is ast.CallExpr && (is_top_level || p.tok.kind != .rcbr)
&& left0 !is ast.PostfixExpr && !(left0 is ast.InfixExpr && left0 !is ast.PostfixExpr && !(left0 is ast.InfixExpr
&& (left0 as ast.InfixExpr).op in [.left_shift, .arrow]) && left0 !is ast.ComptimeCall && (left0 as ast.InfixExpr).op in [.left_shift, .arrow]) && left0 !is ast.ComptimeCall

View File

@ -178,7 +178,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
} }
field_start_pos := p.tok.position() field_start_pos := p.tok.position()
is_embed := ((p.tok.lit.len > 1 && p.tok.lit[0].is_capital()) is_embed := ((p.tok.lit.len > 1 && p.tok.lit[0].is_capital())
|| p.peek_tok.kind == .dot) && language == .v || p.peek_tok.kind == .dot) && language == .v && p.peek_tok.kind != .key_fn
is_on_top := ast_fields.len == 0 && !(is_field_mut || is_field_mut || is_field_global) is_on_top := ast_fields.len == 0 && !(is_field_mut || is_field_mut || is_field_global)
mut field_name := '' mut field_name := ''
mut typ := table.Type(0) mut typ := table.Type(0)