-
The compiler now issues a friendlier error when attempting to pattern match on both the prefix and suffix of a string:
error: Syntax error ┌─ /src/parse/error.gleam:2:23 │ 2 │ "prefix" <> infix <> "suffix" -> infix │ ^^^^^^^^^^^ This pattern is not allowed A string pattern can only match on a literal string prefix. Matching on a literal suffix is not possible, because `infix` would have an unknown size. -
Improved the error message shown when using an invalid discard name for functions, constants, module names, and
aspatterns. (Giacomo Cavalieri) -
The compiler now generates singleton values for variants with no fields on the JavaScript target, allowing for faster comparison in most cases. (Surya Rose)
-
The use of pipes to turn the Gleam code
a |> b(c)intob(c)(a)has been deprecated. (Surya Rose) -
The compiler now gives a better error message when an
@externalattribute is incomplete. For example:@external pub fn wibble()
now points to the attribute itself and explains that it is incomplete. (Asish Kumar)
-
The "did you mean one of these:" hint is now phrased in singular when there is only one suggestion, additionally multiple suggestions are listed in a consistent alphabetical order. (Zbyněk Juřica)
-
The build tool now generates Hexdocs URLs using the new format of
package.hexdocs.pmrather thanhexdocs.pm/package. (Surya Rose) -
More readable error message when trying to revert an old release. (Moritz Böhme)
-
The build tool now includes destination path in the error when it fails to link or copy file or directory. (Andrey Kozhev)
-
Git dependencies now support an optional
pathfield to specify a subdirectory within the repository. This is useful for monorepos that contain multiple Gleam packages. For example:[dependencies] my_package = { git = "https://github.com/example/monorepo", ref = "main", path = "packages/my_package", }
-
The
gleam hex owner transfercommand now uses the flag--userinstead of the flag--to. Thegleam hex owner addcommand now takes the package name via the flag--package. (Louis Pilfold) -
The error message when failing to decrypt the local Hex API key is now more informative and helpful. (Moritz Böhme)
-
The build tool can now authenticate requests to Hex with the API key from the
HEXPM_READ_API_KEYenvironment variable, when resolving and downloading dependencies. This raises the request rate limit from the stricter per-IP limit to the higher per-user limit, avoiding "rate limit exceeded" errors when building large projects. (John Downey)
-
The language server now supports go-to-definition, find-references and rename for record fields. These work on the field declaration, on labelled arguments, on labelled patterns, on record updates and on
record.fieldaccesses, both within a module and across modules. For example:pub type Person { Person(name: String, age: Int) } pub fn main() { let lucy = Person(name: "Lucy", age: 10) lucy.name // ^ Go-to-definition jumps to the `name` field, and renaming it here // renames the field everywhere it is used. }
-
The "pattern match on value" code action can now be used to pattern match on values returned by function calls. For example:
pub fn main() { load_user() // ^^ Triggering the code action over here } fn load_user() -> Result(User, Nil) { todo }
Will produce the following code:
pub fn main() { case load_user() { Ok(value) -> todo Error(value) -> todo } }
-
The language server now offers a code action to rewrite integers in a different base. For example:
pub fn lucky_number() { 0b1011 //^^^^^^ Hovering this }
The language server is going to show code actions to rewrite it as
11,0o13, or0xB. (Giacomo Cavalieri) -
The "remove unreachable patterns" code action can now be triggered on unreachable alternative patterns of a case expression. (Giacomo Cavalieri)
-
The language server now permits renaming type variables in functions, types, and constants. For example:
pub fn twice(value: a, f: fn(a) -> a) -> a { // ^ Rename to "anything" f(f(value)) }
Produces:
pub fn twice(value: anything, f: fn(anything) -> anything) -> anything { f(f(value)) }
-
The language server now automatically updates imports when a Gleam module is renamed. For example:
import db_users pub fn main() -> db_users.User { db_users.new("username") }
Renaming
db_users.gleamtodatabase/user.gleamwould produce:import database/user pub fn main() -> user.User { user.new("username") }
-
The language server now offers a code action to generate a missing type definition when an unknown type is referenced. For example, if
Wibbleis not defined:pub fn run(data: Wibble(Int)) { todo }
The code action will generate:
pub type Wibble(a) pub fn run(data: Wibble(Int)) { todo }
-
The language server now has "Discard unused variable" code action to discard unused variables in different places. For example,
pub type Wibble { Wibble(a: Int) } pub fn go(record: Wibble) -> Nil { let wibble = 0 // ^ Trigger code action here case record { Wibble(a:) -> Nil // ^ Trigger code action here } case [0, 1, 2] { [_, ..] as wobble -> Nil // ^ Trigger code action here [] -> Nil } Nil }
Triggering the code action in all of these places would produce following code:
pub type Wibble { Wibble(a: Int) } pub fn go(record: Wibble) -> Nil { let _wibble = 0 case record { Wibble(a: _) -> Nil } case [0, 1, 2] { [_, ..] -> Nil [] -> Nil } Nil }
-
The language server will now better rename types and values with import aliases by removing
as ...part in case new name is same as original name of item. For example:import wibble.{type Wibble as Wobble, Wibble as Wobble} pub fn go() -> Wobble { // ^^^^^^ Rename to `Wibble` Wobble //^^^^^^ Rename to `Wibble` }
Will now result in this code:
import wibble.{type Wibble, Wibble} pub fn go() -> Wibble { Wibble }
-
The language server now supports folding of comments and documentation comments. For example, this code:
//// Very useful module. //// //// It could be used to make interesting things /// Function to wibble. /// /// Not that it wobbles when wubble is true pub fn wibble() { // This todo here is temporary. // It will need to be removed at some moment. todo }
can now be folded to:
//// Very useful module. ... /// Function to wibble. ... pub fn wibble() { // This todo here is temporary. ... todo }
-
The "Convert to function call" code action will now convert the currently hovered call and not only the final one. (Andrey Kozhev)
-
When using the "Extract function" code action on statements whose values are unused, the extracted function will return the last statement. For example:
fn main() { //↓ start selection here echo "line 2" echo "line 3" // ↑ end selection here echo "line 4" }
will be turned into
fn main() { function() echo "line 4" } fn function() -> String { echo "line 2" echo "line 3" }
-
The language server now offers a code action to fix the new deprecated pipeline syntax. (Surya Rose)
-
The language server can now find references for and rename items when triggered from an import statement:
import wibble.{type Wibble} // ^^^^^^ Trigger find references or rename here pub fn main() { let _ = Wibble }
-
The language server now has "Convert to documentation comment" and "Convert to regular comment" code actions. For example:
// Module description. // Code action available here. // Comment before function. // Another code action here. pub fn wibble() { // No code action here. todo } /// Doc comment. /// Another code action here. pub fn wobble () { todo }
Triggering the code actions in all of these places will result in:
//// Module description. //// Code action available here. /// Comment before function. /// Another code action here. pub fn wibble() { // No code action here. todo } // Doc comment. // Another code action here. pub fn wobble () { todo }
-
Performance of the formatter has been improved.
gleam formathas been measured to be up to 13% faster on projects likelustre, with a 10% smaller peak memory footprint. (Giacomo Cavalieri) -
Formatter now removes import aliases if the aliased name is the same as the original name. For example,
import wibble.{Wibble as Wibble}
becomes
import wibble.{Wibble}
-
Fixed a bug where the generated Erlang
.appfile'smoduleslist would only contain the modules recompiled by the latest build, becoming empty on a warm rebuild where nothing changed. (Charlie Tonneslan) -
When using the language server to extract a function from within an anonymous function, the return value of the extracted function is respected.
For example,
fn wibble() { let wobble = fn() { let random_number = 4 random_number * 42 // <- Extracting this line } }
is turned into
fn wibble() { let wobble = fn() { let random_number = 4 function(random_number) } } fn function(random_number: Int) -> Int { random_number * 42 }
-
Work around an ambiguity of the language server protocol that resulted in editors like Zed inserting the wrong text when accepting type completions. (Giacomo Cavalieri)
-
Fixed a bug where the post-publish message for pushing a git commit was formatted incorrectly. (Louis Pilfold)
-
Fixed a bug where the compiler would generate invalid TypeScript type definitions for records with a field named
constructor. (Giacomo Cavalieri) -
Fixed a bug where the compiler would generate invalid code for
let assertexpression with bit array patterns. (Giacomo Cavalieri) -
Fixed a bug where the compiler would evaluate the numerator and denominator of a division in the wrong order. (Giacomo Cavalieri)
-
Fixed a bug where the compiler would generate Erlang code that raises further warnings for unused values. (Giacomo Cavalieri)
-
Fixed a bug where the compiler would raise a warning for truncated int segments when compiling a function with a JavaScript external. (Giacomo Cavalieri)
-
Fixed a bug where the compiler would produce a confusing error message when writing a constructor with a lowercase name. (Giacomo Cavalieri)
-
A
gleam@@compile.erlis no longer left in the build output ofgleam compile-package. (Louis Pilfold) -
When using the language server to extract a function from within the body of a use statement, only the selected statement(s) are extracted.
For example,
pub fn wibble() { use wobble <- result.map(todo) echo wobble as "1" // <- Extracting this line echo wobble as "2" }
is turned into
pub fn wibble() { use wobble <- result.map(todo) function(wobble) echo wobble as "2" } fn function(wobble: a) -> a { echo wobble as "1" }
-
Fixed a bug where the JavaScript code generator could produce duplicate
letdeclarations when a variable was reassigned after being shadowed inside a directly matchingcasebranch. (Eyup Can Akman) -
Fixed a bug where the language server would produce wrong code when triggering rename of types and values with import aliases. (Andrey Kozhev)
-
Fixed a bug where referencing qualified constructors in constant where a value of the same name exists in scope would cause invalid code to be generated. (Surya Rose)
-
Fixed a bug that would result in
gleam buildbeing slower than necessary when finding the Gleam files of a package. (Giacomo Cavalieri) -
Fixed a bug where the compiler would not be able to correctly parse negative numbers written in binary, octal, or hexadecimal base. (Giacomo Cavalieri)
-
The formatter now properly formats binary operations in bit array size segments. (Andrey Kozhev)
-
Fixed a bug where after removing dependencies with
gleam removeif a removed dependency is still used the build would succeed, resulting in runtime crash due to missing files. (Andrey Kozhev) -
The build tool will no longer panic when unable to lock the build directory. (Louis Pilfold)
-
The formatter now properly indents multiline trailing comments inside of multiline lists and tuples. (0xda157)
-
Fixed a bug where the compiler would panic on the first HTTPS request on Android. (John Downey)
-
Fixed a bug where the language server would not show autocomplete for record fields of internal types within the same package. (Surya Rose)
-
Fixed a bug where warnings and errors in the arguments of a call to a function literal would be reported multiple times. (John Downey)
-
Fixed a bug where pattern matching on overlapping string prefixes with guards could generate incorrect JavaScript. (John Downey)
-
Fixed a bug where running
gleam docs buildon non-Erlang target projects with a warm cache would not produce the module pages. (Matt Champagne) -
Fixed a bug where an incorrect
package-interface.jsonwould be generated for certain type aliases. (Surya Rose) -
Fixed a bug where the compiler would report a module import as unused when its local name matched another imported module's full name. (John Downey)