Skip to content

Latest commit

 

History

History
246 lines (178 loc) · 7.51 KB

CHANGELOG.md

File metadata and controls

246 lines (178 loc) · 7.51 KB

Changelog

Unreleased

Compiler

  • Removed compiler hint about pattern matching a Result(a, b) when being used where a is 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 todo expression. (Giacomo Cavalieri)

  • The shorthand names for the two targets, erl and js are now deprecated in code such as @target.

    (Surya Rose)

  • 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"

    (Surya Rose)

  • When targeting JavaScript the compiler now generates faster and smaller code for Int values 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 @deprecated attribute:

    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 .mjs and .erl) are now permitted in subdirectories of src/ and test/. (PgBiel)

  • gleam publish now requires more verbose confirmation for publishing Gleam team packages and v0 packages. (Louis Pilfold)

  • gleam publish now 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_stdlib v0.44.0.

  • gleam remove no 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.

    (Surya Rose)

  • 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)
      })
    }

    (Giacomo Cavalieri)

  • 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)
    }

    (Giacomo Cavalieri)

  • 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 let assignment into a case expression:

    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
    }

    (Surya Rose)

Formatter

Bug fixed

  • The compiler now throws an error when a float literal ends with an e and 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 use expressions would not be checked to ensure that they were exhaustive. (Surya Rose)

  • Fixed a bug where a module.mjs file would be overwritten by a module.gleam file 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)

v1.6.1 - 2024-11-19

Bug fixed

  • Fixed a bug where gleam update would fail to update versions. (Jason Sipula)