From 0a03856c83ddf4fc7cf7c6660db63fea8d51a8b9 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 12 Feb 2021 09:12:22 +0100 Subject: [PATCH] parser: small c2v fixes --- vlib/v/checker/checker.v | 2 +- vlib/v/parser/containers.v | 2 +- vlib/v/parser/parser.v | 3 ++- vlib/v/parser/struct.v | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 1145ea12ba..b817ba2831 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 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) } for generic_type in call_expr.generic_types { diff --git a/vlib/v/parser/containers.v b/vlib/v/parser/containers.v index ae70ee3ba8..b487d1480e 100644 --- a/vlib/v/parser/containers.v +++ b/vlib/v/parser/containers.v @@ -80,7 +80,7 @@ fn (mut p Parser) array_init() ast.ArrayInit { first_pos.extend(last_pos)) } } 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() is_fixed = true has_val = true diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index ddd4126432..e8bf9496c1 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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() { 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.PostfixExpr && !(left0 is ast.InfixExpr && (left0 as ast.InfixExpr).op in [.left_shift, .arrow]) && left0 !is ast.ComptimeCall diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 0a12cfa0ad..e9b761d77e 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -178,7 +178,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl { } field_start_pos := p.tok.position() 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) mut field_name := '' mut typ := table.Type(0)