Changelog#
Unreleased#
Compiler#
-
Removed compiler hint about pattern matching a
Result(a, b)when being used whereais expected. (Kieran O'Reilly) -
Optimised code generated for record updates. (yoshi)
-
The compiler now allows for record updates to change the generic type parameters of the record:
type Box(value) { Box(password: String, value: value) } fn insert(box: Box(a), value: b) -> Box(b) { Box(..box, value:) }(yoshi)
-
It is now allowed to write a block with no expressions. Like an empty function body, an empty block is considered incomplete as if it contained a
todoexpression. (Giacomo Cavalieri) -
The shorthand names for the two targets,
erlandjsare now deprecated in code such as@target. -
A custom panic message can now be specified when asserting a value with
let assert:let assert Ok(regex) = regex.compile("ab?c+") as "This regex is always valid" -
When targeting JavaScript the compiler now generates faster and smaller code for
Intvalues in bit array expressions and patterns by evaluating them at compile time where possible. (Richard Viney) -
Qualified records can now be used in clause guards. (Surya Rose)
-
The compiler now allows deprecating specific custom type variants using the
@deprecatedattribute:pub type HashAlgorithm { @deprecated("Please upgrade to another algorithm") Md5 Sha224 Sha512 } pub fn hash_password(input: String) -> String { hash(input:, algorithm: Md5) // Warning: Deprecated value used }(Iesha)
-
On the JavaScript target, taking byte-aligned slices of bit arrays is now an O(1) operation instead of O(N), significantly improving performance. (Richard Viney)
-
Better error message for existed type constructor being used as value constructor. (Jiangda Wang)
Build tool#
-
Improved the error message you get when trying to add a package that doesn't exist with
gleam add. (Giacomo Cavalieri) -
External files (such as
.mjsand.erl) are now permitted in subdirectories ofsrc/andtest/. (PgBiel) -
gleam publishnow requires more verbose confirmation for publishing Gleam team packages and v0 packages. (Louis Pilfold) -
gleam publishnow warns when publishing packages that define multiple top-level modules, as this can lead to namespace pollution and conflicts for consumers. (Aleksei Gurianov) -
New projects now require
gleam_stdlibv0.44.0. -
gleam removeno longer requires a network connection. (yoshi) -
Commands that work with the Hex package manager API now create and store an API key rather than creating a new one each time. This API key is encrypted with a local password, reducing risk of your Hex password being compromised. (Louis Pilfold)
Language Server#
-
The language server now provides type information when hovering over argument labels.
-
The Language Server now suggests a code action to desugar a use expression into the equivalent function call. For example, this snippet of code:
pub fn main() { use profile <- result.try(fetch_profile(user)) render_welcome(user, profile) }Will be turned into:
pub fn main() { result.try(fetch_profile(user), fn(profile) { render_welcome(user, profile) }) } -
The Language Server now suggests a code action to turn a function call into the equivalent use expression. For example, this snippet of code:
pub fn main() { result.try(fetch_profile(user) fn(profile) { render_welcome(user, profile) }) }Will be turned into:
pub fn main() { use profile <- result.try(fetch_profile(user)) render_welcome(user, profile) } -
The language server now provides correct information when hovering over patterns in use expressions.
-
The language server now suggests a code action to convert an inexhaustive
letassignment into acaseexpression:pub fn unwrap_result(result: Result(a, b)) -> a { let Ok(inner) = result inner }Becomes:
pub fn unwrap_result(result: Result(a, b)) -> a { let inner = case result { Ok(inner) -> inner Error(_) -> todo } inner }
Formatter#
- The formatter now adds a
todoinside empty blocks. (Giacomo Cavalieri)
Bug fixed#
-
The compiler now throws an error when a float literal ends with an
eand is missing an exponent. (Surya Rose) -
Fixed a crash with ENOTEMPTY (os error 39) when building on NTFS partitions (Ivan Ermakov)
-
Fixed a bug where the compiler would crash when pattern matching on multiple subjects and one of them being a constant record. (Surya Rose)
-
Variant inference on prelude types now works correctly if the variant is constant. (Surya Rose)
-
Fixed a bug where patterns in
useexpressions would not be checked to ensure that they were exhaustive. (Surya Rose) -
Fixed a bug where a
module.mjsfile would be overwritten by amodule.gleamfile of same name without warning. It now produces an error. (PgBiel) -
Modules depending on removed or renamed modules now get automatically recompiled. (Sakari Bergen)
-
The compiler now raises a warning for unused case expressions, code blocks and pipelines that would be safe to remove. (Giacomo Cavalieri)
-
Fixed a bug where assigning the prefix of a string pattern to a variable nested inside another pattern would produce invalid code on Javascript. (yoshi)
-
Fixed a bug where expressions which use an unsafe integer on JavaScript would not emit a warning if an @external function had been referenced. (Richard Viney)
-
Fixed a bug where nested tuple access would not be parsed correctly when the left-hand side was a function call. (Surya Rose)
-
Fixed a bug where Gleam would be unable to compile to BEAM bytecode on older versions of Erlang/OTP. (yoshi)
-
Fixed a bug where the inferred variant of values was not properly cached, leading to incorrect errors on incremental builds and in the Language Server. (Surya Rose)
-
Fixed a bug where Gleam would be unable to compile to BEAM bytecode if the project path contains a non-ascii character. (yoshi)
v1.6.1 - 2024-11-19#
Bug fixed#
- Fixed a bug where
gleam updatewould fail to update versions. (Jason Sipula)