diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46a61f35b3..2dc4ad6fd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,6 +56,7 @@ jobs: ./v fmt -verify vlib/v/fmt/fmt.v ./v fmt -verify vlib/v/parser/parser.v ./v fmt -verify vlib/v/gen/cgen.v + ./v fmt -verify vlib/v/gen/x64/gen.v # - name: Test v binaries # run: ./v -silent build-vbinaries diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index fd08903303..397e7efba3 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1060,9 +1060,10 @@ pub fn (mut f Fmt) expr(node ast.Expr) { f.write(')') } ast.UnsafeExpr { - f.writeln('unsafe {') - f.stmts(node.stmts) - f.writeln('}') + f.write('unsafe {') + es := node.stmts[0] as ast.ExprStmt + f.expr(es.expr) + f.write('}') } } } diff --git a/vlib/v/fmt/tests/blocks_expected.vv b/vlib/v/fmt/tests/blocks_expected.vv index ac9d9e2608..988f8a883c 100644 --- a/vlib/v/fmt/tests/blocks_expected.vv +++ b/vlib/v/fmt/tests/blocks_expected.vv @@ -1,6 +1,6 @@ fn unsafe_fn() { unsafe { - malloc(2) + _ = malloc(2) } } diff --git a/vlib/v/fmt/tests/blocks_input.vv b/vlib/v/fmt/tests/blocks_input.vv index 1761ca6ff8..6efacaa1b1 100644 --- a/vlib/v/fmt/tests/blocks_input.vv +++ b/vlib/v/fmt/tests/blocks_input.vv @@ -1,5 +1,5 @@ fn unsafe_fn() { -unsafe { malloc(2) } +unsafe { _ = malloc(2) } } fn fn_with_defer() { diff --git a/vlib/v/tests/unsafe_test.v b/vlib/v/tests/unsafe_test.v index 82e06e1440..d0b672c067 100644 --- a/vlib/v/tests/unsafe_test.v +++ b/vlib/v/tests/unsafe_test.v @@ -24,14 +24,8 @@ fn test_ptr_assign() { fn test_ptr_infix() { v := 4 - mut q := unsafe { - &v - 1 - } - - q = unsafe { - q + 3 - } - + mut q := unsafe {&v - 1} + q = unsafe {q + 3} _ := q _ := v }