Repository: domluna/JuliaFormatter.jl (julia)

Issue:
Parse error using @inbounds inside an expression
The following is properly formatted by `JuliaFormatter`:

```
threads_count = @inbounds min(remaining_batches_count, threads_count_of_processes[worker_id])
```

But the following fails with a parse error:

```
threads_count = min(remaining_batches_count, @inbounds threads_count_of_processes[worker_id])
```

BTW, it would be nice if, when there is a parse error, there was some indication of where the error was in the file... I had to do a binary search to isolate this line.

Pull request description:
When `CSTParser.MacroCall` was split into itself and `MacroBlock` it was forgotten not to add a trailing comma if the final element is a `MacroBlock`.

difference for reference:

```
MacroCall @call(a, b)
MacroBlock @call a
```

fixes #248

Patch:
diff --git a/src/fst.jl b/src/fst.jl
index d4322d192..e887cd60c 100644
--- a/src/fst.jl
+++ b/src/fst.jl
@@ -207,6 +207,7 @@ function add_node!(t::FST, n::FST, s::State; join_lines = false, max_padding = -
            en.typ === CSTParser.Filter ||
            en.typ === CSTParser.Flatten ||
            en.typ === CSTParser.MacroCall ||
+           en.typ === MacroBlock ||
            (is_comma(en) && t.typ === CSTParser.TupleH && n_args(t.ref[]) == 1)
             # don't insert trailing comma in these cases
         elseif is_comma(en)


Test patch:
diff --git a/test/default_style.jl b/test/default_style.jl
index 38509913f..f9521517a 100644
--- a/test/default_style.jl
+++ b/test/default_style.jl
@@ -4781,4 +4781,16 @@ some_function(
                arg2"""
         @test fmt(str_, 4, 1) == str
     end
+
+    @testset "issue 248" begin
+        str_ = """
+        var = call(a, @macrocall b)"""
+        str = """
+        var =
+            call(
+                a,
+                @macrocall b
+            )"""
+        @test fmt(str_, 4, 1) == str
+    end
 end