Changelog#
v1.10.0 - 2025-04-14#
Bug fixes#
-
Fixed a bug where the code action to unqualify types and values would add an unqualified import even if it was already imported. (Surya Rose)
-
Fixed a bug where numbers starting with
0x_,0o_and0b_would cause a syntax error when compiling to JavaScript. (Surya Rose)
v1.10.0-rc1 - 2025-04-05#
Compiler#
-
On the JavaScript target, bit arrays can now use the
unitoption to control the units of thesizeoption. (Surya Rose) -
The compiler can now tell if string branches are unreachable. For example, the following code:
case a_string { "Hello, " <> name -> name "Hello, Jak" -> "Jak" _ -> "Stranger" }Will raise the following warning:
warning: Unreachable case clause ┌─ /src/greet.gleam:7:5 │ 7 │ "Hello, Jak" -> "Jak" │ ^^^^^^^^^^^^^^^^^^^^^ This case clause cannot be reached as a previous clause matches the same values. Hint: It can be safely removed. -
On the JavaScript target, blocks and various other expressions no longer compile to immediately invoked function expressions. (Surya Rose)
-
On the JavaScript target, bit arrays can now use 16-bit floats in expressions and patterns. (Richard Viney)
-
Improved the error message for unknown and missing target names in the
@targetattribute. (Alexander Keleschovsky) -
The compiler now uses a call graph for detecting unused types and values. This means that among other things, it can now detect unused recursive functions. For example:
// warning: unused fn some_recursive_function() { some_recursive_function() } -
The compiler now emits a warning when using
let assertto assert a value whose variant has already been inferred. For example:// warning: This will always crash let assert Ok(_) = Error("Some error") -
It is now possible to omit the
:floatoption for literal floats used in aBitArraysegment.<<1.11>>Is the same as:
<<1.11:float>> -
Compilation of binary operators is now fault tolerant and won't stop at the first type error. (Giacomo Cavalieri)
-
The compiler now provides a better error message when using the wrong operator to try and join two strings together. For example:
error: Type mismatch ┌─ /src/wibble.gleam:2:13 │ 2 │ "Hello, " + "Lucy" │ ^ Use <> instead The + operator can only be used on Ints. To join two strings together you can use the <> operator. -
The compiler now provides a better error message when using an Int operator on Float values, suggesting the correct replacement. For example:
error: Type mismatch ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:2:7 │ 2 │ 1.0 + 2.0 │ ^ Use +. instead The + operator can only be used on Ints. -
The compiler now provides a better error message when using a Float operator on Int values, suggesting the correct replacement. For example:
error: Type mismatch ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:2:5 │ 2 │ 1 >. 2 │ ^^ Use > instead The >. operator can only be used on Floats. -
The compiler no longer shows errors for a function's labels if the called function itself doesn't exist. (Giacomo Cavalieri)
Build tool#
-
Include a type annotation for the
mainfunction generated bygleam new. (Drew Olson) -
Two entry point scripts are now always generated by
gleam export erlang-shipment:entrypoint.shfor POSIX Shellentrypoint.ps1for PowerShell
-
The
gleam exportcommand now takes apackage-informationoption to export the project'sgleam.tomlas a JSON file. (Rodrigo Álvarez) -
Improved the error message when failing to encrypt or decrypt a local Hex API key. (Samuel Cristobal)
-
The
HEXPM_USERandHEXPM_PASSenvironment variables when runninggleam publishhave been deprecated in favour ofHEXPM_API_KEY. (Samuel Cristobal) -
The "functions" and "constants" sections of generated HTML documentation have been merged into one "values" section. (Sam Zanca)
Language server#
-
The language server now allows renaming of functions, constants, custom type variants and custom types across modules. For example:
// wibble.gleam pub fn wibble() { wibble() //^ Trigger rename } // wobble.gleam import wibble pub fn main() { wibble.wibble() }Becomes:
// wibble.gleam pub fn wobble() { wobble() } // wobble.gleam import wibble pub fn main() { wibble.wobble() } -
The language server can now offer a code action to replace a
..in a pattern with all the fields that are being ignored. For example triggering the code action on this spread:pub type Pokemon { Pokemon(id: Int, name: String, moves: List(String)) } pub fn main() { let Pokemon(..) = todo // ^ If you put your cursor here }Would generate the following code:
pub type Pokemon { Pokemon(id: Int, name: String, moves: List(String)) } pub fn main() { let Pokemon(id:, name:, moves:) = todo } -
The function generated by the "Generate JSON encoder" code action has been slightly modified so that it will now fail to compile if the type has new fields added, ensuring the programmer remembers to re-run the code action. For example, for this type:
type Person { Person(name: String, age: Int) }The following code used to be generated:
fn encode_person(person: Person) -> json.Json { json.object([ #("name", json.string(person.name)), #("age", json.int(person.age)), ]) }But now, this code is generated:
fn encode_person(person: Person) -> json.Json { let Person(name:, age:) = person json.object([ #("name", json.string(name)), #("age", json.int(age)), ]) } -
The language server now supports finding references to values and types, both within a module and across multiple modules. (Surya Rose)
-
The language server now offers a code action to remove all
echos in a module. For example:pub fn main() { [1, 2, 3] |> echo // ^^^^ If you put your cursor over here |> list.filter(int.is_even) |> echo }Triggering the code action would remove all the
echopipeline steps:pub fn main() { [1, 2, 3] |> list.filter(int.is_even) }This also works with all the
echos used before an expression:pub fn main() { echo 1 + 2 //^^^^^^^^^^ If hovering anywhere over here }Triggering the code action would remove the
echo:pub fn main() { 1 + 2 } -
The language server now offers a code action to replace a Float operator used on Int values with the correct operator. For example:
pub fn main() { 11 +. 1 //^^^^^^^ When hovering anywhere over here }Triggering the code action would fix the compilation error by using the correct Int operator:
pub fn main() { 11 + 1 }This also works the other way around:
pub fn main() { 1.1 + 10.0 //^^^^^^^^^^ If hovering anywhere over here }Triggering the code action would replace the wrong operator with the correct equivalent Float operator:
pub fn main() { 1.1 +. 10.0 } -
If there's a compilation error because two strings are being joined with the wrong
+operator (instead of using<>), the language server now offers a code action to fix the error automatically. For example:pub fn main() { "Hello, " + "Jak" //^^^^^^^^^^^^^^^^^ When hovering anywhere over here }Triggering the code action would fix the compilation error by using the correct
<>operator instead of+:pub fn main() { "Hello, " <> "Jak" } -
The language server now offers the option to lift expressions into consts. For example, in two uses of the code action:
pub fn main() { [#("a", 0), #("b", 1), #("a", 2)] |> key_filter("a") }Becomes:
const values = [#("a", 0), #("b", 1), #("a", 2)] const string = "a" pub fn main() { values |> key_filter(string) } -
The language server will now only offer the code action to generate a JSON encoder if the
gleam_jsonpackage is installed as a dependency. (Surya Rose) -
The language server will offer to wrap assignment or case clause values in blocks. Useful when adding more expressions to an existing case clause or variable assignment.
pub fn f(pokemon_type: PokemonType) { case pokemon_type { Water -> soak() // ^^^^^^ selecting the right-hand side of the `->` in a clause Fire -> burn() } }Becomes
pub fn f(pokemon_type: PokemonType) { case pokemon_type { Water -> { soak() } Fire -> burn() } } -
The "Generate function" code action now uses labels or variable names to improve the names of generated arguments. For example:
pub fn main() { let language = English greet(language, name: "Louis") }Will generate the following function:
pub fn greet(language: String, name name: String) -> a { todo } -
The "Rewrite from
use" code action now only triggers if the cursor is on the first line of theuseexpression to rewrite. (Giacomo Cavalieri)
Formatter#
Container images#
- Container images now contain Software Bill of Materials (SBoM) and SLSA Provenance information. (Jonatan Männchen)
Bug fixes#
-
Fixed a bug where tuples with atoms in the first position could be incorrectly formatted by
echo. (Louis Pilfold) -
Fixed a bug where unlabelled arguments would be allowed after labelled arguments in variant constructor definitions. (Surya Rose)
-
Fixed a bug where using the "Convert to pipe" code action on a function whose first argument is itself a pipe would result in invalid code. (Giacomo Cavalieri)
-
Fixed a bug where using the "Convert to pipe" code action on a function or record capture produces invalid code. (Matias Carlander)
-
Fixed a bug where a temporarily moved or removed file does not get recompiled, even though its dependencies changed in the meanwhile. (Sakari Bergen)
-
Fixed a bug where the "Inline variable" code action would not work properly if used inside a record update. (Surya Rose)
-
Fixed a bug where variant inference wouldn't work on
let assertassignments. (Giacomo Cavalieri) -
Fixed a bug where the build tool could fail to lock the build directory but not report an error. (Louis Pilfold)
-
Fixed a bug where the language server would be too eager to recompile modules when it could use the cache from previous compilations. (Louis Pilfold)
-
Fixed a bug where
let assertwould not assert that the given value matched the pattern if it was the only expression inside a block. (Surya Rose) -
Fixed a bug where the code generated for
echoon JavaScript could have name collisions if there are functions calledconsoleorprocess, or custom type variants calledObjectorDenodefined in the module. (Louis Pilfold) -
Fixed a bug where the language server would stop working if the build directory was deleted e.g. as a result of
gleam clean. (Sakari Bergen) -
Fixed a bug where the "Rewrite to pipe" code action could generate invalid code when the piped argument was a binary operation. (Giacomo Cavalieri)
-
Fixed a bug where prelude types and values would be suggested in autocomplete when part of a module select. (Surya Rose)
-
Fixed a bug where the check for multiple top-level modules when publishing would incorrectly print a warning. (Surya Rose)
v1.9.1 - 2025-03-10#
Formatter#
- Improved the formatting of pipelines printed with
echo. (Giacomo Cavalieri)
Bug fixes#
- Fixed a bug where
echoused before a pipeline would generate invalid code for the Erlang target. (Giacomo Cavalieri)