File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -2637,17 +2637,17 @@ pub fn (mut f Fmt) selector_expr(node ast.SelectorExpr) {
2637
2637
2638
2638
pub fn (mut f Fmt) size_of (node ast.SizeOf) {
2639
2639
f.write ('sizeof' )
2640
- if node.is_type {
2641
- // keep the old form for now
2642
- f.write ('( ' )
2640
+ if node.is_type && ! node.guessed_type {
2641
+ // the new form was explicitly written in the source code; keep it:
2642
+ f.write ('[ ' )
2643
2643
f.write (f.table.type_to_str_using_aliases (node.typ, f.mod2 alias))
2644
- f.write (')' )
2644
+ f.write (']( )' )
2645
2645
return
2646
2646
}
2647
2647
if node.is_type {
2648
- f.write ('[ ' )
2648
+ f.write ('( ' )
2649
2649
f.write (f.table.type_to_str_using_aliases (node.typ, f.mod2 alias))
2650
- f.write (']( )' )
2650
+ f.write (')' )
2651
2651
} else {
2652
2652
f.write ('(' )
2653
2653
f.expr (node.expr)
@@ -2657,17 +2657,17 @@ pub fn (mut f Fmt) size_of(node ast.SizeOf) {
2657
2657
2658
2658
pub fn (mut f Fmt) is_ref_type (node ast.IsRefType) {
2659
2659
f.write ('isreftype' )
2660
- if node.is_type {
2661
- // keep the old form for now
2662
- f.write ('( ' )
2660
+ if node.is_type && ! node.guessed_type {
2661
+ // the new form was explicitly written in the source code; keep it:
2662
+ f.write ('[ ' )
2663
2663
f.write (f.table.type_to_str_using_aliases (node.typ, f.mod2 alias))
2664
- f.write (')' )
2664
+ f.write (']( )' )
2665
2665
return
2666
2666
}
2667
2667
if node.is_type {
2668
- f.write ('[ ' )
2668
+ f.write ('( ' )
2669
2669
f.write (f.table.type_to_str_using_aliases (node.typ, f.mod2 alias))
2670
- f.write (']( )' )
2670
+ f.write (')' )
2671
2671
} else {
2672
2672
f.write ('(' )
2673
2673
f.expr (node.expr)
Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ fn test_isreftype() {
29
29
assert isreftype (S4 ) == false
30
30
assert isreftype (S5 ) == true
31
31
assert isreftype (f64 ) == false
32
- assert isreftype ([ ]f64 ) == true
33
- assert isreftype ([ 3 ]int ) == false
32
+ assert isreftype[[ ]f64 ]( ) == true
33
+ assert isreftype[[ 3 ]int ]( ) == false
34
34
}
35
35
36
36
fn check_ref [T]() string {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ fn test_math_sizeof() {
16
16
17
17
fn test_sizeof () {
18
18
assert sizeof (rune ) == 4
19
- assert sizeof ([ 44 ]u8 ) == 44
19
+ assert sizeof [[ 44 ]u8 ]( ) == 44
20
20
assert sizeof (`€` ) == 4
21
21
// depends on -m32/64
22
22
assert sizeof (S1 ) in [u32 (4 ), 8 ]
You can’t perform that action at this time.
0 commit comments