-
The
--no-print-progress
flag has been added to prevent the build tool from printing messages as the project is built. (Ankit Goel) -
The compiler is now able to run a dependency's module using
gleam run -m
even when there's compilation errors in your own project's code. (Giacomo Cavalieri) -
HTML docs: make module names in sidebar wrap before a / when possible (Jiangda Wang)
-
The printing of runtime errors has been improved, including those from linked processes. (Louis Pilfold)
-
OTP application trees are now shut down gracefully when
main
exits. (Louis Pilfold) -
The
gleam fix
command can now update a project'sgleam
version contraint to make sure it respects the inferred minimum required version. (Giacomo Cavalieri) -
The build tool now refuses to publish a project where the
gleam
version constraint would include a compiler version that doesn't support the features used by the package. (Giacomo Cavalieri) -
If a project doesn't specify a
gleam
version constraint, the build tool will automatically infer it and add it to the project'sgleam.toml
before publishing it. (Giacomo Cavalieri)
-
Compiler progress is now printed to stderr, instead of stdout. (Victor Kobinski)
-
It is now possible to omit the
:utf8
option for literal strings used in aBitArray
segment.<<"Hello", " ", "world">>
Is the same as:
<<"Hello":utf8, " ":utf8, "world":utf8>>
-
In inexhaustive pattern match errors the missing variants are now printed using the correct syntax for the module the error is emitted in, rather than the module it was defined in. For example, if you had this code:
import gleam/option pub fn main() { let an_option = option.Some("wibble!") case an_option { option.None -> "missing" } }
The error message would show the qualified
option.Some(_)
as the missing pattern:error: Inexhaustive patterns ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:5:3 │ 5 │ ╭ case an_option { 6 │ │ option.None -> "missing" 7 │ │ } │ ╰───^ This case expression does not have a pattern for all possible values. If it is run on one of the values without a pattern then it will crash. The missing patterns are: option.Some(_)
-
Anonymous functions that are immediately called with a record or a tuple as an argument are now inferred correctly without the need to add type annotations. For example you can now write:
fn(x) { x.0 }(#(1, 2)) // ^ you no longer need to annotate this!
(sobolevn)
-
Anonymous functions that are being piped a record or a tuple as an argument are now inferred correctly without the need to add type annotations. For example you can now write:
pub type User { User(name: String) } pub fn main() { User("Giacomo") |> fn(user) { user.name } // ^^^^ you no longer need to annotate this! |> io.debug }
(sobolevn)
-
The record pattern matching syntax
Record(a ..)
is now deprecated in favour of theRecord(a, ..)
syntax. (Giacomo Cavalieri) -
Adds a better error message when module names are used as values. For example the following code:
import gleam/list pub fn main() { list }
Results in the error:
error: Module `list` used as a value ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:4:3 │ 4 │ list │ ^^^^ Modules are not values, so you cannot assign them to variables, pass them to functions, or anything else that you would do with a value.
(sobolevn)
-
An helpful error message has been added when the programmer attempts to write a function within a custom type definition, likely trying to declare an OOP class. For example:
pub type User { User(name: String) fn greet(user: User) -> String { "hello " <> user.name } }
Now results in the following error:
error: Syntax error ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:8:3 │ 8 │ fn greet(user: User) -> String { │ ^^ I was not expecting this Found the keyword `fn`, expected one of: - `}` - a record constructor Hint: Gleam is not an object oriented programming language so functions are declared separately from types.
(sobolevn)
-
The compiler now gives a hint to import a module when accessing modules that aren't imported. It only suggests a module if it exports a type/value with the same name as what the user was trying to access:
pub fn main() { io.println("Hello, world!") }
Produces the following error:
error: Unknown module ┌─ /src/file.gleam:2:3 │ 2 │ io.println("Hello, world!") │ ^^ No module has been found with the name `io`. Hint: Did you mean to import `gleam/io`?
This code, however, produces no hint:
pub fn main() { io.non_existent() }
-
The compiler now provides improved suggestions in the error for an inexhaustive case expression. The following code:
let a = True case a {}
Now produces this error:
error: Inexhaustive patterns ┌─ /src/file.gleam:3:3 │ 3 │ case a {} │ ^^^^^^^^^ This case expression does not have a pattern for all possible values. If it is run on one of the values without a pattern then it will crash. The missing patterns are: False True
Whereas before, it would suggest
_
as the only missing pattern. (Surya Rose) -
Improve error message for using
@external
with unknown target (Jiangda Wang) -
Improved error title when using an unknown module value. (Giacomo Cavalieri)
-
The compiler now shows an helpful error message if you try writing an
if
expression instead of a case. For example, this code:pub fn main() { let a = if wibble { 1 } }
Results in the following error:
error: Syntax error ┌─ /src/parse/error.gleam:3:11 │ 3 │ let a = if wibble { │ ^^ Gleam doesn't have if expressions If you want to write a conditional expression you can use a `case`: case condition { True -> todo False -> todo } See: https://tour.gleam.run/flow-control/case-expressions/
-
The compiler can now infer the minimum Gleam version needed for your code to compile and emits a warning if the project's
gleam
version constraint doesn't include it. For example, let's say yourgleam.toml
has the constraintgleam = ">= 1.1.0"
and your code is using some feature introduced in a later version:// Concatenating constant strings was introduced in v1.4.0! pub const greeting = "hello " <> "world!"
You would now get the following warning:
warning: Incompatible gleam version range ┌─ /Users/giacomocavalieri/Desktop/datalog/src/datalog.gleam:1:22 │ 1 │ pub const greeting = "hello " <> "world!" │ ^^^^^^^^^^^^^^^^^^^^ This requires a Gleam version >= 1.4.0 Constant strings concatenation was introduced in version v1.4.0. But the Gleam version range specified in your `gleam.toml` would allow this code to run on an earlier version like v1.1.0, resulting in compilation errors! Hint: Remove the version constraint from your `gleam.toml` or update it to be: gleam = ">= 1.4.0"
-
On the JavaScript target, non-byte aligned integers in bit array patterns are now reported as a compile-time error.
-
The formatter now adds a
todo
after ause
expression if it is the last expression in a block. For example, the following code:pub fn main() { use user <- result.try(fetch_user()) }
Is rewritten as:
pub fn main() { use user <- result.try(fetch_user()) todo }
-
The language server can now show completions for local variables inside a function. (Ezekiel Grosfeld)
-
The language server can now suggest a code action to assign an unused value to
_
. (Jiangda Wang) -
The language server can now suggest a code action to import modules for existing code which references unimported modules:
pub fn main() { io.println("Hello, world!") }
Becomes:
import gleam/io pub fn main() { io.println("Hello, world!") }
-
The Language Server can now suggest a code action to fill in the missing patterns of a case expression:
let a = True case a {}
Becomes:
let a = True case a { False -> todo True -> todo }
-
Fixed a bug where the warnings were printed above the errors without any new line between them. (Victor Kobinski)
-
Fixed a bug which caused the language server and compiler to crash when two constructors of the same name were created. (Surya Rose)
-
Fixed a bug where jumping to the definition of an unqualified function would produce the correct location, but remain in the same file. (Surya Rose)
-
Fixed a bug where incorrect syntax error message were shown, when using
:
or=
in wrong positions in expressions. (Ankit Goel) -
Fixed a bug where the compiler would crash when pattern matching on a type which had constructors of duplicate names. (Surya Rose)
-
Fixed a bug where referencing record constructors in JavaScript constants but not calling them could produce invalid code. (Louis Pilfold)
-
Fixed a bug where source links in HTML documentation would be incorrect for Codeberg, SourceHut, and Gitea. (sobolevn)
-
Fixed a bug with Erlang code generation for discard utf8 patterns in bit arrays. (Giacomo Cavalieri)
-
Fixed a bug which affected inference of function calls in pipe expressions. (sobolevn)
-
Improved an error message when using variable names starting with an underscore in expression like:
let some = _func()
orcase { 1 -> _func() }
(sobolevn) -
Fixed a bug where the provided
REBAR_BARE_COMPILER_OUTPUT_DIR
env var would use relative path instead of absolute path causing compilation errors in some packages. (Gustavo Inacio) -
Fixed a bug where the compiler would print incorrect missing patterns for inexhaustive case expressions matching on more than one subject. (Surya Rose)
-
Fixed a bug where the compiler would not check the target support of a function if it was imported and not used, and generate invalid code. (Surya Rose)
-
Fixed a bug where an qualified unused constructor wouldn't be reported as unused. (Giacomo Cavalieri)
-
The Language Server now correctly shows completions for values in the Gleam prelude. (Surya Rose)
-
Fixed a bug where the language server wouldn't let you jump to the definition of a function with an external implementation defined in the same module. (Giacomo Cavalieri)
- Fix a bug that caused record accessors for private types to not be completed by the LSP, even when in the same module. (Ameen Radwan)