diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 4e76758276..aee1efe656 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -235,10 +235,8 @@ pub mut: // root_ident returns the origin ident where the selector started. pub fn (e &SelectorExpr) root_ident() ?Ident { mut root := e.expr - for root is SelectorExpr { - // TODO: remove this line - selector_expr := root as SelectorExpr - root = selector_expr.expr + for mut root is SelectorExpr { + root = root.expr } if root is Ident { return root as Ident @@ -1184,16 +1182,6 @@ pub: pos token.Position } -// NB: &string(x) gets parsed as PrefixExpr{ right: CastExpr{...} } -// TODO: that is very likely a parsing bug. It should get parsed as just -// CastExpr{...}, where .typname is '&string' instead. -// The current situation leads to special cases in vfmt and cgen -// (see prefix_expr_cast_expr in fmt.v, and .is_amp in cgen.v) -// .in_prexpr is also needed because of that, because the checker needs to -// show warnings about the deprecated C->V conversions `string(x)` and -// `string(x,y)`, while skipping the real pointer casts like `&string(x)`. -// 2021/07/17: TODO: since 6edfb2c, the above is fixed at the parser level, -// we need to remove the hacks/special cases in vfmt and the checker too. pub struct CastExpr { pub: arg Expr // `n` in `string(buf, n)` diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 08fcdd1780..96fb617bc1 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -1113,10 +1113,6 @@ pub fn (t &Table) value_type(typ Type) Type { // bytes[0] is a byte, not byte* return typ.deref() } - // TODO: remove when map_string is removed - if typ_sym.name == 'map_string' { - return string_type - } return void_type } diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 62297b98a1..8f4c9082eb 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -713,7 +713,7 @@ pub fn (mut f Fmt) assign_stmt(node ast.AssignStmt) { f.is_assign = true f.write(' $node.op.str() ') for i, val in node.right { - f.prefix_expr_cast_expr(val) + f.expr(val) if i < node.right.len - 1 { f.write(', ') } @@ -2230,7 +2230,7 @@ pub fn (mut f Fmt) prefix_expr(node ast.PrefixExpr) { } } f.write(node.op.str()) - f.prefix_expr_cast_expr(node.right) + f.expr(node.right) f.or_expr(node.or_block) } @@ -2441,26 +2441,6 @@ pub fn (mut f Fmt) unsafe_expr(node ast.UnsafeExpr) { f.write('}') } -pub fn (mut f Fmt) prefix_expr_cast_expr(node ast.Expr) { - mut is_pe_amp_ce := false - if node is ast.PrefixExpr { - if node.right is ast.CastExpr && node.op == .amp { - mut ce := node.right - ce.typname = f.table.get_type_symbol(ce.typ).name - is_pe_amp_ce = true - f.expr(ce) - } - } else if node is ast.CastExpr { - last := f.out.cut_last(1) - if last != '&' { - f.out.write_string(last) - } - } - if !is_pe_amp_ce { - f.expr(node) - } -} - fn (mut f Fmt) trace(fbase string, message string) { if f.file.path_base == fbase { println('> f.trace | ${fbase:-10s} | $message') diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 5efdfbd9e8..46af440a5d 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -140,7 +140,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) { f.indent++ inc_indent = true } - f.prefix_expr_cast_expr(field.default_expr) + f.expr(field.default_expr) if inc_indent { f.indent-- inc_indent = false @@ -207,7 +207,7 @@ pub fn (mut f Fmt) struct_init(node ast.StructInit) { f.write(', ') } for i, field in node.fields { - f.prefix_expr_cast_expr(field.expr) + f.expr(field.expr) if i < node.fields.len - 1 { f.write(', ') } @@ -257,7 +257,7 @@ pub fn (mut f Fmt) struct_init(node ast.StructInit) { } for i, field in node.fields { f.write('$field.name: ') - f.prefix_expr_cast_expr(field.expr) + f.expr(field.expr) f.comments(field.comments, inline: true, has_nl: false, level: .indent) if single_line_fields { if i < node.fields.len - 1 {