Repository: domluna/JuliaFormatter.jl (julia)

Issue:
Incorrect handling of `..` in `using` statements
Formatting the following text
```julia
using Measurements: (..)
```

Outputs the error
```
┌ Warning: Failed to format file /Users/jonnie.diegelman/github/FlightSystems/blah.jl due to a parsing error, skipping file
│   error =
│    ParseError:
│    # Warning @ line 1:21
│    using Measurements: (..)
│    #                   └──┘ ── parentheses are not required here
└ @ JuliaFormatter ~/.julia/packages/JuliaFormatter/D3w1R/src/JuliaFormatter.jl:448
```

This is incorrect. The parentheses are required, otherwise the code is not able to be parsed.

JuliaFormatter version: `v2.1.2`
Output of `versioninfo()`:
```
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 4 default, 0 interactive, 2 GC (on 4 virtual cores)
```

Pull request description:
Fixes https://github.com/domluna/JuliaFormatter.jl/issues/917.

Patch:
diff --git a/src/JuliaFormatter.jl b/src/JuliaFormatter.jl
index 8a76dd6cc..74721bfcc 100644
--- a/src/JuliaFormatter.jl
+++ b/src/JuliaFormatter.jl
@@ -207,7 +207,7 @@ function format_text(text::AbstractString, style::AbstractStyle, opts::Options)
     if opts.always_for_in == true
         @assert valid_for_in_op(opts.for_in_replacement) "`for_in_replacement` is set to an invalid operator \"$(opts.for_in_replacement)\", valid operators are $(VALID_FOR_IN_OPERATORS). Change it to one of the valid operators and then reformat."
     end
-    t = JuliaSyntax.parseall(JuliaSyntax.GreenNode, text)
+    t = JuliaSyntax.parseall(JuliaSyntax.GreenNode, text; ignore_warnings = true)
     state = State(Document(text), opts)
     text = format_text(t, style, state)
     return text
@@ -277,7 +277,7 @@ function format_text(node::JuliaSyntax.GreenNode, style::AbstractStyle, s::State
     text = normalize_line_ending(text, replacer)
 
     try
-        _ = JuliaSyntax.parseall(JuliaSyntax.GreenNode, text)
+        _ = JuliaSyntax.parseall(JuliaSyntax.GreenNode, text; ignore_warnings = true)
     catch err
         @warn "Formatted text is not parsable ... no change made."
         rethrow(err)


Test patch:
diff --git a/test/issues.jl b/test/issues.jl
index 14ea67d9c..a9976c518 100644
--- a/test/issues.jl
+++ b/test/issues.jl
@@ -1947,4 +1947,10 @@
         """
         @test fmt(str_, 4, 100) == s
     end
+
+    @testset "917" begin
+        s = "using Foo: ( .. )"
+        sf = "using Foo: (..)"
+        @test fmt(s, 4, 100) == sf
+    end
 end