v.ast: fix `dump(os.real_path(Makefile))` printing `main.os.real_path`

pull/13710/head
Delyan Angelov 2022-03-10 11:11:09 +02:00
parent 4bea35b028
commit e8c8f0e7c0
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 22 additions and 5 deletions

View File

@ -311,6 +311,9 @@ pub fn (x Expr) str() string {
if x.mod == '' && x.name == '' {
return x.left.str() + '($sargs)$propagate_suffix'
}
if x.name.contains('.') {
return '${x.name}($sargs)$propagate_suffix'
}
return '${x.mod}.${x.name}($sargs)$propagate_suffix'
}
CharLiteral {

View File

@ -1,17 +1,19 @@
[vlib/v/tests/inout/dump_expression.vv:2] 1: 1
[vlib/v/tests/inout/dump_expression.vv:7] 'a': a
[vlib/v/tests/inout/dump_expression.vv:23] p: Point{
[vlib/v/tests/inout/dump_expression.vv:4] 1: 1
[vlib/v/tests/inout/dump_expression.vv:9] 'a': a
[vlib/v/tests/inout/dump_expression.vv:25] p: Point{
x: 1
y: 2
z: 3
}
[vlib/v/tests/inout/dump_expression.vv:24] p_mut: Point{
[vlib/v/tests/inout/dump_expression.vv:26] p_mut: Point{
x: 1
y: 2
z: 3
}
[vlib/v/tests/inout/dump_expression.vv:25] p_ptr: &Point{
[vlib/v/tests/inout/dump_expression.vv:27] p_ptr: &Point{
x: 1
y: 2
z: 3
}
[vlib/v/tests/inout/dump_expression.vv:38] os.file_name(vexe).replace('.exe', ''): v
[vlib/v/tests/inout/dump_expression.vv:41] f.read(mut buf): 10

View File

@ -1,3 +1,5 @@
import os
fn dump_of_int() {
x := dump(1) + 1
assert x == 2
@ -31,8 +33,18 @@ fn dump_of_struct() {
assert x3 == Point{101, 2, 3}
}
fn dump_of_callexpr() {
vexe := @VEXE
dump(os.file_name(vexe).replace('.exe', ''))
mut f := os.open_file(os.join_path(os.dir(vexe), 'Makefile'), 'r') or { return }
mut buf := []byte{len:10}
dump( f.read(mut buf) or { -999 })
f.close()
}
fn main() {
dump_of_int()
dump_of_string()
dump_of_struct()
dump_of_callexpr()
}