Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / CHANGELOG.md
18 kB 658 lines
1<!-- 2 SPDX-License-Identifier: Apache-2.0 3 SPDX-FileCopyrightText: 2020 The Gleam contributors 4--> 5 6# Changelog 7 8## v1.18.0-rc2 - 2026-07-25 9 10### Bug fixes 11 12- Fixed a bug where the compiler would crash when wrapping an error message 13 whose line broke in the middle of a multi-byte UTF-8 character. 14 ([John Downey](https://github.com/jtdowney)) 15 16- Fixed a bug where invalid JavaScript would be generated for code which used a 17 bit array pattern to extract a `Float` and had a constructor called `Number`. 18 ([Surya Rose](https://github.com/GearsDatapacks)) 19 20- Fixed a bug where `-0.0` would be encoded incorrectly in 16-bit bit array 21 segments on the JavaScript target. 22 ([Surya Rose](https://github.com/GearsDatapacks)) 23 24- Fixed a bug where the formatter would insert underscores into negative 25 hexadecimal, octal, and binary literals, producing code that no longer 26 compiles. 27 ([John Downey](https://github.com/jtdowney)) 28 29- Fixed a bug where type annotations on discarded variables in `use` bindings 30 were ignored. 31 ([Francesco Cappetti](https://github.com/frakappa)) 32 33- Fixed a bug where the language server would crash on code that contains syntax 34 errors. 35 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 36 37- Fixed a bug where bit array segments would not be compiled properly, using an 38 invalid Erlang segment option. 39 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 40 41## v1.18.0-rc1 - 2026-07-21 42 43### Compiler 44 45- The compiler now issues a friendlier error when attempting to pattern match 46 on both the prefix and suffix of a string: 47 48 ``` 49 error: Syntax error 50 ┌─ /src/parse/error.gleam:2:23 51 52 2 │ "prefix" <> infix <> "suffix" -> infix 53 │ ^^^^^^^^^^^ This pattern is not allowed 54 55 A string pattern can only match on a literal string prefix. 56 57 Matching on a literal suffix is not possible, because `infix` would have an 58 unknown size. 59 ``` 60 61 ([Gavin Morrow](https://github.com/gavinmorrow)) 62 63- Improved the error message shown when using an invalid discard name for 64 functions, constants, module names, and `as` patterns. 65 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 66 67- The compiler now generates singleton values for variants with no fields on the 68 JavaScript target, allowing for faster comparison in most cases. 69 ([Surya Rose](https://github.com/GearsDatapacks)) 70 71- The use of pipes to turn the Gleam code `a |> b(c)` into `b(c)(a)` has been 72 deprecated. 73 ([Surya Rose](https://github.com/GearsDatapacks)) 74 75- The compiler now gives a better error message when an `@external` 76 attribute is incomplete. For example: 77 78 ```gleam 79 @external 80 pub fn wibble() 81 ``` 82 83 now points to the attribute itself and explains that it is incomplete. 84 ([Asish Kumar](https://github.com/officialasishkumar)) 85 86- The "did you mean one of these:" hint is now phrased in singular when there 87 is only one suggestion, additionally multiple suggestions are listed 88 in a consistent alphabetical order. 89 ([Zbyněk Juřica](https://github.com/zbyju)) 90 91### Build tool 92 93- The build tool now generates Hexdocs URLs using the new format of 94 `package.hexdocs.pm` rather than `hexdocs.pm/package`. 95 ([Surya Rose](https://github.com/GearsDatapacks)) 96 97- More readable error message when trying to revert an old release. 98 ([Moritz Böhme](https://github.com/MoritzBoehme)) 99 100- The build tool now includes destination path in the error when it fails to 101 link or copy file or directory. 102 ([Andrey Kozhev](https://github.com/ankddev)) 103 104- Git dependencies now support an optional `path` field to specify a 105 subdirectory within the repository. This is useful for monorepos that 106 contain multiple Gleam packages. For example: 107 108 ```toml 109 [dependencies] 110 my_package = { 111 git = "https://github.com/example/monorepo", 112 ref = "main", 113 path = "packages/my_package", 114 } 115 ``` 116 117 ([John Downey](https://github.com/jtdowney)) 118 119- The `gleam hex owner transfer` command now uses the flag `--user` instead of 120 the flag `--to`. The `gleam hex owner add` command now takes the package name 121 via the flag `--package`. 122 ([Louis Pilfold](https://github.com/lpil)) 123 124- The error message when failing to decrypt the local Hex API key is now more 125 informative and helpful. 126 ([Moritz Böhme](https://github.com/MoritzBoehme)) 127 128- The build tool can now authenticate requests to Hex with the API key from the 129 `HEXPM_READ_API_KEY` environment variable, when resolving and downloading 130 dependencies. This raises the request rate limit from the stricter per-IP 131 limit to the higher per-user limit, avoiding "rate limit exceeded" errors 132 when building large projects. 133 ([John Downey](https://github.com/jtdowney)) 134 135### Language server 136 137- The language server now supports go-to-definition, find-references and rename 138 for record fields. These work on the field declaration, on labelled arguments, 139 on labelled patterns, on record updates and on `record.field` accesses, both 140 within a module and across modules. For example: 141 142 ```gleam 143 pub type Person { 144 Person(name: String, age: Int) 145 } 146 147 pub fn main() { 148 let lucy = Person(name: "Lucy", age: 10) 149 lucy.name 150 // ^ Go-to-definition jumps to the `name` field, and renaming it here 151 // renames the field everywhere it is used. 152 } 153 ``` 154 155 ([Alistair Smith](https://github.com/alii)) 156 157- The "pattern match on value" code action can now be used to pattern match on 158 values returned by function calls. For example: 159 160 ```gleam 161 pub fn main() { 162 load_user() 163 // ^^ Triggering the code action over here 164 } 165 166 fn load_user() -> Result(User, Nil) { todo } 167 ``` 168 169 Will produce the following code: 170 171 ```gleam 172 pub fn main() { 173 case load_user() { 174 Ok(value) -> todo 175 Error(value) -> todo 176 } 177 } 178 ``` 179 180 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 181 182- The language server now offers a code action to rewrite integers in a 183 different base. For example: 184 185 ```gleam 186 pub fn lucky_number() { 187 0b1011 188 //^^^^^^ Hovering this 189 } 190 ``` 191 192 The language server is going to show code actions to rewrite it as `11`, 193 `0o13`, or `0xB`. 194 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 195 196- The "remove unreachable patterns" code action can now be triggered on 197 unreachable alternative patterns of a case expression. 198 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 199 200- The language server now permits renaming type variables in functions, types, 201 and constants. For example: 202 203 ```gleam 204 pub fn twice(value: a, f: fn(a) -> a) -> a { 205 // ^ Rename to "anything" 206 f(f(value)) 207 } 208 ``` 209 210 Produces: 211 212 ```gleam 213 pub fn twice(value: anything, f: fn(anything) -> anything) -> anything { 214 f(f(value)) 215 } 216 ``` 217 218 ([Surya Rose](https://github.com/GearsDatapacks)) 219 220- The language server now automatically updates imports when a Gleam module is 221 renamed. For example: 222 223 ```gleam 224 import db_users 225 226 pub fn main() -> db_users.User { 227 db_users.new("username") 228 } 229 ``` 230 231 Renaming `db_users.gleam` to `database/user.gleam` would produce: 232 233 ```gleam 234 import database/user 235 236 pub fn main() -> user.User { 237 user.new("username") 238 } 239 ``` 240 241 ([Surya Rose](https://github.com/GearsDatapacks)) 242 243- The language server now offers a code action to generate a missing type 244 definition when an unknown type is referenced. For example, if `Wibble` 245 is not defined: 246 247 ```gleam 248 pub fn run(data: Wibble(Int)) { todo } 249 ``` 250 251 The code action will generate: 252 253 ```gleam 254 pub type Wibble(a) 255 256 pub fn run(data: Wibble(Int)) { todo } 257 ``` 258 259 ([Daniele Scaratti](https://github.com/lupodevelop)) 260 261- The language server now has "Discard unused variable" code action to discard 262 unused variables in different places. For example, 263 264 ```gleam 265 pub type Wibble { 266 Wibble(a: Int) 267 } 268 269 pub fn go(record: Wibble) -> Nil { 270 let wibble = 0 271 // ^ Trigger code action here 272 273 case record { 274 Wibble(a:) -> Nil 275 // ^ Trigger code action here 276 } 277 278 case [0, 1, 2] { 279 [_, ..] as wobble -> Nil 280 // ^ Trigger code action here 281 [] -> Nil 282 } 283 284 Nil 285 } 286 ``` 287 288 Triggering the code action in all of these places would produce following code: 289 290 ```gleam 291 pub type Wibble { 292 Wibble(a: Int) 293 } 294 295 pub fn go(record: Wibble) -> Nil { 296 let _wibble = 0 297 298 case record { 299 Wibble(a: _) -> Nil 300 } 301 302 case [0, 1, 2] { 303 [_, ..] -> Nil 304 [] -> Nil 305 } 306 307 Nil 308 } 309 ``` 310 311 ([Andrey Kozhev](https://github.com/ankddev)) 312 313- The language server will now better rename types and values with import 314 aliases by removing `as ...` part in case new name is same as original name of 315 item. For example: 316 317 ```gleam 318 import wibble.{type Wibble as Wobble, Wibble as Wobble} 319 320 pub fn go() -> Wobble { 321 // ^^^^^^ Rename to `Wibble` 322 Wobble 323 //^^^^^^ Rename to `Wibble` 324 } 325 ``` 326 327 Will now result in this code: 328 329 ```gleam 330 import wibble.{type Wibble, Wibble} 331 332 pub fn go() -> Wibble { 333 Wibble 334 } 335 ``` 336 337 ([Andrey Kozhev](https://github.com/ankddev)) 338 339- The language server now supports folding of comments and documentation 340 comments. For example, this code: 341 342 ```gleam 343 //// Very useful module. 344 //// 345 //// It could be used to make interesting things 346 347 /// Function to wibble. 348 /// 349 /// Not that it wobbles when wubble is true 350 pub fn wibble() { 351 // This todo here is temporary. 352 // It will need to be removed at some moment. 353 todo 354 } 355 ``` 356 357 can now be folded to: 358 359 ```gleam 360 //// Very useful module. ... 361 362 /// Function to wibble. ... 363 pub fn wibble() { 364 // This todo here is temporary. ... 365 todo 366 } 367 ``` 368 369 ([Andrey Kozhev](https://github.com/ankddev)) 370 371- The "Convert to function call" code action will now convert the currently 372 hovered call and not only the final one. 373 ([Andrey Kozhev](https://github.com/ankddev)) 374 375- When using the "Extract function" code action on statements whose values are 376 unused, the extracted function will return the last statement. For example: 377 378 ```gleam 379 fn main() { 380 //↓ start selection here 381 echo "line 2" 382 echo "line 3" 383 // ↑ end selection here 384 echo "line 4" 385 } 386 ``` 387 388 will be turned into 389 390 ```gleam 391 fn main() { 392 function() 393 echo "line 4" 394 } 395 396 fn function() -> String { 397 echo "line 2" 398 echo "line 3" 399 } 400 ``` 401 402 ([Gavin Morrow](https://github.com/gavinmorrow)) 403 404- The language server now offers a code action to fix the new deprecated pipeline 405 syntax. 406 ([Surya Rose](https://github.com/GearsDatapacks)) 407 408- The language server can now find references for and rename items when 409 triggered from an import statement: 410 411 ```gleam 412 import wibble.{type Wibble} 413 // ^^^^^^ Trigger find references or rename here 414 415 pub fn main() { 416 let _ = Wibble 417 } 418 ``` 419 420 ([Gavin Morrow](https://github.com/gavinmorrow)) 421 422- The language server now has "Convert to documentation comment" and 423 "Convert to regular comment" code actions. For example: 424 425 ```gleam 426 // Module description. 427 // Code action available here. 428 429 // Comment before function. 430 // Another code action here. 431 pub fn wibble() { 432 // No code action here. 433 todo 434 } 435 436 /// Doc comment. 437 /// Another code action here. 438 pub fn wobble () { 439 todo 440 } 441 ``` 442 443 Triggering the code actions in all of these places will result in: 444 445 ```gleam 446 //// Module description. 447 //// Code action available here. 448 449 /// Comment before function. 450 /// Another code action here. 451 pub fn wibble() { 452 // No code action here. 453 todo 454 } 455 456 // Doc comment. 457 // Another code action here. 458 pub fn wobble () { 459 todo 460 } 461 ``` 462 463 ([Daniel Venable](https://github.com/DanielVenable)) 464 465- The "Generate Variant" code action now includes the name of the type to add 466 the variant to in its title. 467 ([0xda157](https://github.com/0xda157)) 468 469### Formatter 470 471- Performance of the formatter has been improved. 472 `gleam format` has been measured to be up to 13% faster on projects like 473 `lustre`, with a 10% smaller peak memory footprint. 474 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 475 476- Formatter now removes import aliases if the aliased name is the 477 same as the original name. For example, 478 479 ```gleam 480 import wibble.{Wibble as Wibble} 481 ``` 482 483 becomes 484 485 ```gleam 486 import wibble.{Wibble} 487 ``` 488 489 ([Daniel Venable](https://github.com/DanielVenable)) 490 491### Bug fixes 492 493- Fixed a bug where the generated Erlang `.app` file's `modules` list would only 494 contain the modules recompiled by the latest build, becoming empty on a warm 495 rebuild where nothing changed. 496 ([Charlie Tonneslan](https://github.com/c-tonneslan)) 497 498- When using the language server to extract a function from within an anonymous 499 function, the return value of the extracted function is respected. 500 501 For example, 502 503 ```gleam 504 fn wibble() { 505 let wobble = fn() { 506 let random_number = 4 507 random_number * 42 // <- Extracting this line 508 } 509 } 510 ``` 511 512 is turned into 513 514 ```gleam 515 fn wibble() { 516 let wobble = fn() { 517 let random_number = 4 518 function(random_number) 519 } 520 } 521 fn function(random_number: Int) -> Int { 522 random_number * 42 523 } 524 ``` 525 526 ([Gavin Morrow](https://github.com/gavinmorrow)) 527 528- Work around an ambiguity of the language server protocol that resulted in 529 editors like Zed inserting the wrong text when accepting type completions. 530 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 531 532- Fixed a bug where the post-publish message for pushing a git commit was 533 formatted incorrectly. 534 ([Louis Pilfold](https://github.com/lpil)) 535 536- Fixed a bug where the compiler would generate invalid TypeScript type 537 definitions for records with a field named `constructor`. 538 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 539 540- Fixed a bug where the compiler would generate invalid code for `let assert` 541 expression with bit array patterns. 542 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 543 544- Fixed a bug where the compiler would evaluate the numerator and denominator 545 of a division in the wrong order. 546 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 547 548- Fixed a bug where the compiler would generate Erlang code that raises further 549 warnings for unused values. 550 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 551 552- Fixed a bug where the compiler would raise a warning for truncated int 553 segments when compiling a function with a JavaScript external. 554 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 555 556- Fixed a bug where the compiler would produce a confusing error message when 557 writing a constructor with a lowercase name. 558 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 559 560- Fixed a bug where guards with comments wouldn't be formatted properly. 561 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 562 563- A `gleam@@compile.erl` is no longer left in the build output of 564 `gleam compile-package`. 565 ([Louis Pilfold](https://github.com/lpil)) 566 567- When using the language server to extract a function from within the body of a 568 use statement, only the selected statement(s) are extracted. 569 570 For example, 571 572 ```gleam 573 pub fn wibble() { 574 use wobble <- result.map(todo) 575 echo wobble as "1" // <- Extracting this line 576 echo wobble as "2" 577 } 578 ``` 579 580 is turned into 581 582 ```gleam 583 pub fn wibble() { 584 use wobble <- result.map(todo) 585 function(wobble) 586 echo wobble as "2" 587 } 588 fn function(wobble: a) -> a { 589 echo wobble as "1" 590 } 591 ``` 592 593 ([Gavin Morrow](https://github.com/gavinmorrow)) 594 595- Fixed a bug where the JavaScript code generator could produce duplicate `let` 596 declarations when a variable was reassigned after being shadowed inside a 597 directly matching `case` branch. 598 ([Eyup Can Akman](https://github.com/eyupcanakman)) 599 600- Fixed a bug where the language server would produce wrong code when triggering 601 rename of types and values with import aliases. 602 ([Andrey Kozhev](https://github.com/ankddev)) 603 604- Fixed a bug where referencing qualified constructors in constant where a value 605 of the same name exists in scope would cause invalid code to be generated. 606 ([Surya Rose](https://github.com/GearsDatapacks)) 607 608- Fixed a bug that would result in `gleam build` being slower than necessary 609 when finding the Gleam files of a package. 610 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 611 612- Fixed a bug where the compiler would not be able to correctly parse negative 613 numbers written in binary, octal, or hexadecimal base. 614 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 615 616- The formatter now properly formats binary operations in bit array size 617 segments. 618 ([Andrey Kozhev](https://github.com/ankddev)) 619 620- Fixed a bug where after removing dependencies with `gleam remove` if a 621 removed dependency is still used the build would succeed, resulting in 622 runtime crash due to missing files. 623 ([Andrey Kozhev](https://github.com/ankddev)) 624 625- The build tool will no longer panic when unable to lock the build directory. 626 ([Louis Pilfold](https://github.com/lpil)) 627 628- The formatter now properly indents multiline trailing comments inside of 629 multiline lists and tuples. 630 ([0xda157](https://github.com/0xda157)) 631 632- Fixed a bug where the compiler would panic on the first HTTPS request on 633 Android. 634 ([John Downey](https://github.com/jtdowney)) 635 636- Fixed a bug where the language server would not show autocomplete for record 637 fields of internal types within the same package. 638 ([Surya Rose](https://github.com/GearsDatapacks)) 639 640- Fixed a bug where warnings and errors in the arguments of a call to a 641 function literal would be reported multiple times. 642 ([John Downey](https://github.com/jtdowney)) 643 644- Fixed a bug where pattern matching on overlapping string prefixes with guards 645 could generate incorrect JavaScript. 646 ([John Downey](https://github.com/jtdowney)) 647 648- Fixed a bug where running `gleam docs build` on non-Erlang target projects 649 with a warm cache would not produce the module pages. 650 ([Matt Champagne](https://github.com/han-tyumi)) 651 652- Fixed a bug where an incorrect `package-interface.json` would be generated for 653 certain type aliases. 654 ([Surya Rose](https://github.com/GearsDatapacks)) 655 656- Fixed a bug where the compiler would report a module import as unused when 657 its local name matched another imported module's full name. 658 ([John Downey](https://github.com/jtdowney))