vfmt: fix `x := *&int(ptr)`

pull/5917/head
Delyan Angelov 2020-07-21 15:58:17 +03:00
parent 35df792c05
commit e1eb9c4ff1
3 changed files with 10 additions and 1 deletions

View File

@ -898,7 +898,7 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
} }
ast.PrefixExpr { ast.PrefixExpr {
f.write(node.op.str()) f.write(node.op.str())
f.expr(node.right) f.prefix_expr_cast_expr( node.right )
} }
ast.RangeExpr { ast.RangeExpr {
f.expr(node.low) f.expr(node.low)

View File

@ -0,0 +1,5 @@
fn main() {
body := [1, 2, 3]
size := *&int(body.data)
eprintln('size: $size')
}

View File

@ -8,6 +8,10 @@ import v.table
import v.token import v.token
pub fn (mut p Parser) expr(precedence int) ast.Expr { pub fn (mut p Parser) expr(precedence int) ast.Expr {
$if trace_parser ? {
tok_pos := p.tok.position()
eprintln('parsing file: ${p.file_name:-30} | tok.kind: ${p.tok.kind:-10} | tok.lit: ${p.tok.lit:-10} | tok_pos: ${tok_pos.str():-45} | expr($precedence)')
}
// println('\n\nparser.expr()') // println('\n\nparser.expr()')
mut typ := table.void_type mut typ := table.void_type
mut node := ast.Expr{} mut node := ast.Expr{}