diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index d6bebd6575..3ac8828598 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -215,14 +215,23 @@ pub fn (x Expr) str() string { return '${it.left.str()} $it.op.str() ${it.right.str()}' } ParExpr { - return it.expr.str() + return '($it.expr)' } PrefixExpr { return it.op.str() + it.right.str() } + RangeExpr { + mut s := '..' + if it.has_low {s = '$it.low ' + s} + if it.has_high {s = s + ' $it.high'} + return s + } SelectorExpr { return '${it.expr.str()}.${it.field_name}' } + SizeOf { + return 'sizeof($it.expr)' + } StringInterLiteral { mut res := []string{} res << "'" @@ -257,10 +266,9 @@ pub fn (x Expr) str() string { UnsafeExpr { return 'unsafe { $it.stmts.len stmts }' } - else { - return '[unhandled expr type ${typeof(x)}]' - } + else {} } + return '[unhandled expr type ${typeof(x)}]' } pub fn (a CallArg) str() string { diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 73c43c208c..048b2d780b 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -903,7 +903,7 @@ pub fn (mut f Fmt) expr(node ast.Expr) { ast.OrExpr { // shouldn't happen, an or expression // is always linked to a call expr - panic('fmt: OrExpr should to linked to CallExpr') + panic('fmt: OrExpr should be linked to CallExpr') } ast.ParExpr { f.write('(')