Skip to content

Commit

Permalink
ast: improve the assert informations
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Oct 28, 2024
1 parent 9c72d94 commit bc0397b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 5 additions & 1 deletion vlib/v/ast/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ pub fn (x &Expr) str() string {
return x.val.str()
}
CastExpr {
return '${global_table.type_to_str(x.typ)}(${x.expr.str()})'
mut type_name := global_table.type_to_str(x.typ)
if global_table.cur_fn != unsafe { nil } {
type_name = util.no_cur_mod(type_name, global_table.cur_fn.mod)
}
return '${type_name}(${x.expr.str()})'
}
CallExpr {
sargs := args2str(x.args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ vlib/v/tests/skip_unused/assert_of_sumtype_values_works_test.vv:5: fn test_ab
Right value (len: 6): `Sum(2)`

vlib/v/tests/skip_unused/assert_of_sumtype_values_works_test.vv:9: fn test_sumtype_literals
> assert main.Sum(1) == main.Sum(2)
Left value (len: 11): `main.Sum(1)`
Right value (len: 11): `main.Sum(2)`

> assert Sum(1) == Sum(2)
Left value (len: 6): `Sum(1)`
Right value (len: 6): `Sum(2)`
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ vlib/v/tests/skip_unused/assert_of_sumtype_values_works_test.vv:5: fn test_ab
Right value (len: 6): `Sum(2)`

vlib/v/tests/skip_unused/assert_of_sumtype_values_works_test.vv:9: fn test_sumtype_literals
> assert main.Sum(1) == main.Sum(2)
Left value (len: 11): `main.Sum(1)`
Right value (len: 11): `main.Sum(2)`

> assert Sum(1) == Sum(2)
Left value (len: 6): `Sum(1)`
Right value (len: 6): `Sum(2)`

0 comments on commit bc0397b

Please sign in to comment.