PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: gleam-lang/gleam (rust)

Issue:
Missing empty line between last warning and first error
When there's both warnings and errors in a Gleam project the last warning and the first error are printed with no empty line separating them
![Screenshot 2024-08-19 alle 18 28 23](https://github.com/user-attachments/assets/d2d340d5-2c80-40cc-9161-607415cd8fbc)


Pull request:
Fix new line bug before warning
Fixed #3535 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c4b8700c..c0bd5392b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -171,6 +171,9 @@
 
 ### Bug Fixes
 
+- Fixed a bug where the warnings were printed above the errors without any new line between them.
+([Victor Kobinski](https://github.com/vkobinski))
+
 - Fixed a bug which caused the language server and compiler to crash when two
   constructors of the same name were created.
   ([Surya Rose](https://github.com/GearsDatapacks))
diff --git a/compiler-core/src/warning.rs b/compiler-core/src/warning.rs
index c3397e22a..113943667 100644
--- a/compiler-core/src/warning.rs
+++ b/compiler-core/src/warning.rs
@@ -1001,10 +1001,10 @@ See: https://tour.gleam.run/functions/pipelines/",
     }
 
     pub fn pretty(&self, buffer: &mut Buffer) {
+        self.to_diagnostic().write(buffer);
         buffer
             .write_all(b"\n")
-            .expect("error pretty buffer write space before");
-        self.to_diagnostic().write(buffer);
+            .expect("error pretty buffer write space after");
     }
 
     pub fn to_pretty_string(&self) -> String {


Test patch:
diff --git a/test-package-compiler/src/snapshots/test_package_compiler__generated_tests__import_shadowed_name_warning.snap b/test-package-compiler/src/snapshots/test_package_compiler__generated_tests__import_shadowed_name_warning.snap
index aee8a906d..518367fa7 100644
--- a/test-package-compiler/src/snapshots/test_package_compiler__generated_tests__import_shadowed_name_warning.snap
+++ b/test-package-compiler/src/snapshots/test_package_compiler__generated_tests__import_shadowed_name_warning.snap
@@ -51,7 +51,6 @@ use_type(Port) ->
 
 
 //// Warning
-
 warning: Unused private constructor
   ┌─ src/two.gleam:9:3
   │
@@ -61,8 +60,8 @@ warning: Unused private constructor
 Hint: You can safely remove it.
 
 
-//// Warning
 
+//// Warning
 warning: Unused private type
   ┌─ src/two.gleam:7:1
   │