this repo has no description
0
fork

Configure Feed

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

Reset changelog

+706 -693
-693
CHANGELOG.md
··· 2 2 3 3 ## Unreleased 4 4 5 - ### Bug fixes 6 - 7 - - Corrected an error message that used incorrect terminology. 8 - ([Louis Pilfold](https://github.com/lpil)) 9 - 10 - ## v1.12.0-rc3 - 2025-07-31 11 - 12 - ### Bug fixes 13 - 14 - - Fixed a bug where using `echo` in a module with a function named `process` 15 - would result in a runtime error on JavaScript. 16 - ([Peter Saxton](https://github.com/CrowdHailer)) 17 - 18 - ## v1.12.0-rc2 - 2025-07-24 19 - 20 - ### Formatter 21 - 22 - - The formatter now allows more control over how bit arrays are split. By adding 23 - a trailing comma at the end of a bit array that can fit on a single line, the 24 - bit array will be split on multiple lines: 25 - 26 - ```gleam 27 - pub fn dgram() -> BitArray { 28 - <<ip_version:4, header_length:4, service_type:8,>> 29 - } 30 - ``` 31 - 32 - Will be formatted as: 33 - 34 - ```gleam 35 - pub fn dgram() -> BitArray { 36 - << 37 - ip_version:4, 38 - header_length:4, 39 - service_type:8, 40 - >> 41 - } 42 - ``` 43 - 44 - By removing the trailing comma, the formatter will try and fit the bit array 45 - on a single line again: 46 - 47 - ```gleam 48 - pub fn dgram() -> BitArray { 49 - << 50 - ip_version:4, 51 - header_length:4, 52 - service_type:8 53 - >> 54 - } 55 - ``` 56 - 57 - Will be formatted back to a single line: 58 - 59 - ```gleam 60 - pub fn dgram() -> BitArray { 61 - <<ip_version:4, header_length:4, service_type:8>> 62 - } 63 - ``` 64 - 65 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 66 - 67 - - The formatter now allows more control over how bit arrays are formatted. 68 - If a bit array is split with multiple segments on the same line, removing the 69 - trailing comma will make sure the formatter keeps each segment on its own 70 - line: 71 - 72 - ```gleam 73 - pub fn dgram() -> BitArray { 74 - << 75 - "This bit array was formatted", "keeping segments on the same line", 76 - "notice how the formatting changes by removing the trailing comma ->", 77 - >> 78 - } 79 - ``` 80 - 81 - Is formatted as: 82 - 83 - ```gleam 84 - pub fn dgram() -> BitArray { 85 - << 86 - "This bit array was formatted", 87 - "keeping segments on the same line", 88 - "notice how the formatting changes by removing the trailing comma ->" 89 - >> 90 - } 91 - ``` 92 - 93 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 94 - 95 - ### Bug fixes 96 - 97 - - Fixed a bug where the formatter would move a comment before `assert` to be 98 - after it. 99 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 100 - 101 - - Fixed a bug where the message following an `echo`, `panic`, `todo`, `assert`, 102 - or `let assert` would not be formatted properly when preceded by a comment. 103 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 104 - 105 - - Fixed a bug where the compiler would generate invalid code for an `assert` 106 - using pipes on the JavaScript target. 107 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 108 - 109 - ## v1.12.0-rc1 - 2025-07-18 110 - 111 5 ### Compiler 112 6 113 - - It is now possible to add a custom message to be printed by `echo`, making it 114 - easier to include additional context to be printed at runtime: 115 - 116 - ```gleam 117 - pub fn main() { 118 - echo 11 as "lucky number" 119 - } 120 - ``` 121 - 122 - Will output to stderr: 123 - 124 - ```txt 125 - /src/module.gleam:2 lucky number 126 - 11 127 - ``` 128 - 129 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 130 - 131 - - Generated JavaScript functions, constants, and custom type constructors now 132 - include any doc comment as a JSDoc comment, making it easier to use the 133 - generated code and browse its documentation from JavaScript. 134 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 135 - 136 - - The code generated for a `case` expression on the JavaScript target is now 137 - reduced in size in many cases. 138 - ([Surya Rose](https://github.com/GearsDatapacks)) 139 - 140 - - The code generators now perform usage-based dead code elimination. Unused 141 - definitions are not longer generated. 142 - ([Louis Pilfold](https://github.com/lpil)) 143 - 144 - - `echo` now has better support for character lists, JavaScript errors, and 145 - JavaScript circular references. 146 - ([Louis Pilfold](https://github.com/lpil)) 147 - 148 - - The look of errors and warnings has been improved. Additional labels providing 149 - context for the error message are no longer highlighted with the same style as 150 - the source of the problem. 151 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 152 - 153 - - Gleam will now emit a helpful message when attempting to import modules using 154 - `.` instead of `/`. 155 - 156 - ```txt 157 - error: Syntax error 158 - ┌─ /src/parse/error.gleam:1:11 159 - 160 - 1 │ import one.two.three 161 - │ ^ I was expecting either `/` or `.{` here. 162 - 163 - Perhaps you meant one of: 164 - 165 - import one/two 166 - import one.{item} 167 - ``` 168 - 169 - ([Zij-IT](https://github.com/zij-it)) 170 - 171 - - The compiler now emits a warning when a top-level constant or function 172 - declaration shadows an imported name in the current module. 173 - ([Aayush Tripathi](https://github.com/aayush-tripathi)) 174 - 175 - - The compiler can now tell when an unknown variable might be referring to an 176 - ignored variable and provide an helpful error message highlighting it. For 177 - example, this piece of code: 178 - 179 - ```gleam 180 - pub fn go() { 181 - let _x = 1 182 - x + 1 183 - } 184 - ``` 185 - 186 - Now results in the following error: 187 - 188 - ``` 189 - error: Unknown variable 190 - ┌─ /src/one/two.gleam:4:3 191 - 192 - 3 │ let _x = 1 193 - │ -- This value is discarded 194 - 4 │ x + 1 195 - │ ^ So it is not in scope here. 196 - 197 - Hint: Change `_x` to `x` or reference another variable 198 - ``` 199 - 200 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 201 - 202 - - The code generated for pattern matching has been optimised on the JavaScript 203 - target to reuse the matched variables when safe to do so. Take the following 204 - snippet of Gleam code: 205 - 206 - ```gleam 207 - pub fn find_book() { 208 - case ask_for_isbn() { 209 - Ok(isbn) -> load_book(isbn) 210 - Error(Nil) -> Error(Nil) 211 - } 212 - } 213 - ``` 214 - 215 - Notice how in the `Error` case we're returning exactly the same value that is 216 - being matched on! Now the compiler will generate the following JavaScript code 217 - instead of allocating a new `Error` variant entirely: 218 - 219 - ```js 220 - export function find_book() { 221 - let result = ask_for_isbn(); 222 - if (result instanceof Ok) { 223 - let isbn = result[0]; 224 - return load_book(isbn); 225 - } else { 226 - // Previously this would have been: `return new Error(undefined);`! 227 - return result; 228 - } 229 - } 230 - ``` 231 - 232 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 233 - 234 - - The compiler now raises a warning when performing a redundant comparison that 235 - it can tell is always going to succeed or fail. For example, this piece of 236 - code: 237 - 238 - ```gleam 239 - pub fn find_line(lines) { 240 - list.find(lines, fn(x) { x == x }) 241 - } 242 - ``` 243 - 244 - Would result in the following warning: 245 - 246 - ``` 247 - warning: Redundant comparison 248 - ┌─ /src/warning.gleam:2:17 249 - 250 - 1 │ list.find(lines, fn(x) { x == x }) 251 - │ ^^^^^^ This is always `True` 252 - 253 - This comparison is redundant since it always succeeds. 254 - ``` 255 - 256 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 257 - 258 - - Attempting to use the list prefix syntax with two lists will now 259 - show a helpful error message. For example, this snippet of code: 260 - 261 - ```gleam 262 - pub fn main() -> Nil { 263 - let xs = [1, 2, 3] 264 - let ys = [5, 6, 7] 265 - [1, ..xs, ..ys] 266 - } 267 - ``` 268 - 269 - Would result in the following error: 270 - 271 - ``` 272 - error: Syntax error 273 - ┌─ /src/parse/error.gleam:5:13 274 - 275 - 5 │ [1, ..xs, ..ys] 276 - │ -- ^^ I wasn't expecting a second list here 277 - │ │ 278 - │ You're using a list here 279 - 280 - Lists are immutable and singly-linked, so to join two or more lists 281 - all the elements of the lists would need to be copied into a new list. 282 - This would be slow, so there is no built-in syntax for it. 283 - ``` 284 - 285 - ([Carl Bordum Hansen](https://github.com/carlbordum)) and 286 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 287 - 288 - - The error message one gets when calling a function with the wrong number of 289 - arguments has been improved and now only suggests the relevant missing labels. 290 - For example, this piece of code: 291 - 292 - ```gleam 293 - pub type Pokemon { 294 - Pokemon(id: Int, name: String, moves: List(String)) 295 - } 296 - 297 - pub fn best_pokemon() { 298 - Pokemon(198, name: "murkrow") 299 - } 300 - ``` 301 - 302 - Would result in the following error, suggesting the missing labels: 303 - 304 - ```txt 305 - error: Incorrect arity 306 - ┌─ /src/main.gleam:6:3 307 - 308 - 6 │ Pokemon(198, name: "murkrow") 309 - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expected 3 arguments, got 2 310 - 311 - This call accepts these additional labelled arguments: 312 - 313 - - moves 314 - ``` 315 - 316 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 317 - 318 - - Code generators now reuse existing variables when possible for the record 319 - update syntax, reducing the size of the generated code and number of 320 - variables defined for both Erlang and JavaScript. 321 - 322 - ```gleam 323 - pub fn main() -> Nil { 324 - let trainer = Trainer(name: "Ash", badges: 0) 325 - battle(Trainer(..trainer, badges: 1)) 326 - } 327 - ``` 328 - 329 - Previously this Gleam code would generate this Erlang code: 330 - 331 - ```erlang 332 - -spec main() -> nil. 333 - main() -> 334 - Trainer = {trainer, 0, <<"Ash"/utf8>>}, 335 - battle( 336 - begin 337 - _record = Trainer, 338 - {trainer, 1, erlang:element(3, _record)} 339 - end 340 - ). 341 - ``` 342 - 343 - Now this code will be generated instead: 344 - 345 - ```erlang 346 - -spec main() -> nil. 347 - main() -> 348 - Trainer = {trainer, 0, <<"Ash"/utf8>>}, 349 - battle({trainer, 1, erlang:element(3, Trainer)}). 350 - ``` 351 - 352 - ([Louis Pilfold](https://github.com/lpil)) 353 - 354 - - The compiler now allows using bit array options to specify endianness when 355 - constructing or pattern matching on UTF codepoints in bit arrays. 356 - ([Surya Rose](https://github.com/GearsDatapacks)) 357 - 358 - - Calculations are now allowed in the size options of bit array patterns. For 359 - example, the following code is now valid: 360 - 361 - ```gleam 362 - let assert <<size, data:bytes-size(size / 8 - 1)>> = some_bit_array 363 - ``` 364 - 365 - ([Surya Rose](https://github.com/GearsDatapacks)) 366 - 367 - - On the Erlang target each generated module enables inlining from the Erlang 368 - compiler. 369 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 370 - 371 - - The code generated for division and modulo operators on the JavaScript target 372 - has been improved to avoid performing needless checks. 373 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 374 - 375 7 ### Build tool 376 8 377 - - `gleam update`, `gleam deps update`, and `gleam deps download` will now print 378 - a message when there are new major versions of packages available. For 379 - example: 380 - 381 - ```text 382 - $ gleam update 383 - Resolving versions 384 - 385 - The following dependencies have new major versions available: 386 - 387 - gleam_http 1.7.0 -> 4.0.0 388 - gleam_json 1.0.1 -> 3.0.1 389 - lustre 3.1.4 -> 5.1.1 390 - ``` 391 - 392 - ([Amjad Mohamed](https://github.com/andho)) 393 - 394 - - The documentation generator now strips trailing slashes from Gitea/Forgejo 395 - hosts so sidebar "Repository" and "View Source" links never include `//`, and 396 - single-line "View Source" anchors emit `#Lx` instead of `#Lx-x`. 397 - ([Aayush Tripathi](https://github.com/aayush-tripathi)) 398 - 399 - - The build tool can now compile packages that will have already booted the 400 - Erlang compiler application instead of failing. 401 - ([Louis Pilfold](https://github.com/lpil)) 402 - 403 - - `gleam deps list` now uses a tab rather than a space as a separator. 404 - ([Louis Pilfold](https://github.com/lpil)) 405 - 406 - - The build tool now also supports `.cjs` files placed in the `src`, `dev` or 407 - `test` directories. 408 - ([yoshi](https://github.com/yoshi-monster)) 409 - 410 - - The build tool now produces better error messages when version resolution 411 - fails. For example: 412 - 413 - ``` 414 - $ gleam add wisp@1 415 - Resolving versions 416 - error: Dependency resolution failed 417 - 418 - There's no compatible version of `gleam_otp`: 419 - - You require wisp >= 1.0.0 and < 2.0.0 420 - - wisp requires mist >= 1.2.0 and < 5.0.0 421 - - mist requires gleam_otp >= 0.9.0 and < 1.0.0 422 - - You require lustre >= 5.2.1 and < 6.0.0 423 - - lustre requires gleam_otp >= 1.0.0 and < 2.0.0 424 - 425 - There's no compatible version of `gleam_json`: 426 - - You require wisp >= 1.0.0 and < 2.0.0 427 - - wisp requires gleam_json >= 3.0.0 and < 4.0.0 428 - - You require gleam_json >= 2.3.0 and < 3.0.0 429 - ``` 430 - 431 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 432 - 433 - - The `repository` section in `gleam.toml` now allows specifying the 434 - `tag-prefix` property, which is prepended to the default tag. 435 - This makes it possible to have multiple packages with different versions in 436 - the same repository (together with `path`), without breaking links to source 437 - code in documentation. 438 - ([Sakari Bergen](https://github.com/sbergen)) 439 - 440 9 ### Language server 441 10 442 - - It is now possible to use the "Pattern match on variable" code action on 443 - variables on the left hand side of a `use`. For example: 444 - 445 - ```gleam 446 - pub type User { 447 - User(id: Int, name: String) 448 - } 449 - 450 - pub fn main() { 451 - use user <- result.try(load_user()) 452 - // ^^^^ Triggering the code action here 453 - todo 454 - } 455 - ``` 456 - 457 - Would result in the following code: 458 - 459 - ```gleam 460 - pub type User { 461 - User(id: Int, name: String) 462 - } 463 - 464 - pub fn main() { 465 - use user <- result.try(load_user()) 466 - let User(id:, name:) = user 467 - todo 468 - } 469 - ``` 470 - 471 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 472 - 473 - - The "generate function" and "generate variant" code actions are now 474 - quickfixes, allowing them to be more easily applied to code which is producing 475 - an error. 476 - ([Surya Rose](https://github.com/GearsDatapacks)) 477 - 478 - - The language server now offers a code action to remove needless blocks 479 - wrapping a single expression. For example, in this code snippet: 480 - 481 - ```gleam 482 - case greeting { 483 - User(name:) -> { "Hello, " <> name } 484 - // ^^^^^^^^^^^^^^^^^^^^^ Triggering the code action 485 - // with the cursor over this block. 486 - Anonymous -> "Hello, stranger!" 487 - } 488 - ``` 489 - 490 - Would be turned into: 491 - 492 - ```gleam 493 - case greeting { 494 - User(name:) -> "Hello, " <> name 495 - Anonymous -> "Hello, stranger!" 496 - } 497 - ``` 498 - 499 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 500 - 501 - - It is now possible to trigger the "Add type annotation" code action anywhere 502 - between the start of a function definition and the start of its body. For 503 - example the action can trigger here while it previously wouldn't: 504 - 505 - ```gleam 506 - pub fn my_lucky_number() { 507 - // ^^ The action can trigger here as well! 508 - 11 509 - } 510 - ``` 511 - 512 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 513 - 514 11 ### Formatter 515 12 516 - - The formatter now allows more control over how lists are split. By adding a 517 - trailing comma at the end of a list that can fit on a single line, the list 518 - will be split on multiple lines: 519 - 520 - ```gleam 521 - pub fn my_favourite_pokemon() -> List(String) { 522 - ["natu", "chimecho", "milotic",] 523 - } 524 - ``` 525 - 526 - Will be formatted as: 527 - 528 - ```gleam 529 - pub fn my_favourite_pokemon() -> List(String) { 530 - [ 531 - "natu", 532 - "chimecho", 533 - "milotic", 534 - ] 535 - } 536 - ``` 537 - 538 - By removing the trailing comma, the formatter will try and fit the list on a 539 - single line again: 540 - 541 - ```gleam 542 - pub fn my_favourite_pokemon() -> List(String) { 543 - [ 544 - "natu", 545 - "chimecho", 546 - "milotic" 547 - ] 548 - } 549 - ``` 550 - 551 - Will be formatted back to a single line: 552 - 553 - ```gleam 554 - pub fn my_favourite_pokemon() -> List(String) { 555 - ["natu", "chimecho", "milotic"] 556 - } 557 - ``` 558 - 559 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 560 - 561 - - The formatter now allows more control over how lists are formatted. 562 - If a list is split with multiple elements on the same line, removing the 563 - trailing comma will make sure the formatter keeps each item on its own line: 564 - 565 - ```gleam 566 - pub fn my_favourite_pokemon() -> List(String) { 567 - [ 568 - "This list was formatted", "keeping multiple elements on the same line", 569 - "notice how the formatting changes by removing the trailing comma ->" 570 - ] 571 - } 572 - ``` 573 - 574 - Is formatted as: 575 - 576 - ```gleam 577 - pub fn my_favourite_pokemon() -> List(String) { 578 - [ 579 - "This list was formatted", 580 - "keeping multiple elements on the same line", 581 - "notice how the formatting changes by removing the trailing comma ->", 582 - ] 583 - } 584 - ``` 585 - 586 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 587 - 588 - - The formatter no longer removes empty lines between list items. In case an 589 - empty line is added between list items they will all be split on multiple 590 - lines. For example: 591 - 592 - ```gleam 593 - pub fn main() { 594 - [ 595 - "natu", "xatu", 596 - 597 - "chimeco" 598 - ] 599 - } 600 - ``` 601 - 602 - Is formatted as: 603 - 604 - ```gleam 605 - pub fn main() { 606 - [ 607 - "natu", 608 - "xatu", 609 - 610 - "chimeco", 611 - ] 612 - } 613 - ``` 614 - 615 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 616 - 617 13 ### Bug fixes 618 - 619 - - Fixed a bug where the language server would not show type-related code actions 620 - for record fields in custom type definitions. 621 - ([cysabi](https://github.com/cysabi)) 622 - 623 - - Fixed a bug where the "Inline variable" code action would be offered for 624 - function parameters and other invalid cases. 625 - ([Surya Rose](https://github.com/GearsDatapacks)) 626 - 627 - - Fixed a bug where the "Inline variable" code action would not be applied 628 - correctly to variables using label shorthand syntax. 629 - ([Surya Rose](https://github.com/GearsDatapacks)) 630 - 631 - - Fixed a bug where the compiler would emit the same error twice for patterns 632 - with the wrong number of labels. 633 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 634 - 635 - - Fixed a bug where the language server would generate invalid code when the 636 - "Extract variable" code action was used on a `use` expression. 637 - ([Surya Rose](https://github.com/GearsDatapacks)) 638 - 639 - - Fixed a bug where the compiler would crash when using the `utf8_codepoint` 640 - bit array segment on the JavaScript target. 641 - ([Surya Rose](https://github.com/GearsDatapacks)) 642 - 643 - - Fixed a bug where `==` and `!=` would return incorrect output for some 644 - JavaScript objects. 645 - ([Louis Pilfold](https://github.com/lpil)) 646 - 647 - - Fixed a bug where specific combinations of options in bit array segments would 648 - not be allowed on the JavaScript target. 649 - ([Surya Rose](https://github.com/GearsDatapacks)) 650 - 651 - - Fixed a bug where invalid code would be generated for `let assert` in some 652 - cases on the JavaScript target. 653 - ([Surya Rose](https://github.com/GearsDatapacks)) 654 - 655 - - Fixed a bug where using the prelude `Ok` and `Error` values in a qualified 656 - fashion could cause a conflict with user-defined `Ok` and `Error` values when 657 - generating code on the JavaScript target. 658 - ([Surya Rose](https://github.com/GearsDatapacks)) 659 - 660 - - Fixed a bug where the "Import module" code action would suggest importing 661 - internal modules from other packages. 662 - ([Surya Rose](https://github.com/GearsDatapacks)) 663 - 664 - - Fixed a bug where the language server would not rename variables defined in 665 - alternative patterns. 666 - ([Surya Rose](https://github.com/GearsDatapacks)) 667 - 668 - - Fixed a bug where trying to rename a type or value from the Gleam prelude 669 - would result in invalid code. 670 - ([Surya Rose](https://github.com/GearsDatapacks)) 671 - 672 - - Fixed a bug where the generated documentation would not be formatted properly. 673 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 674 - 675 - - Fixed a bug where the language server wouldn't allow you to jump to the 676 - definition of a record from a record update expression. 677 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 678 - 679 - - Fixed a bug where the language server would allow using the "extract variable" 680 - code action on variables used in record updates. 681 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 682 - 683 - - Fixed a bug where a record pattern with a spread `..` would not be formatted 684 - properly. 685 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 686 - 687 - - Fixed a bug where fields of custom types named `prototype` would not be 688 - properly escaped on the JavaScript target. 689 - ([Surya Rose](https://github.com/GearsDatapacks)) 690 - 691 - ## v1.11.1 - 2025-06-05 692 - 693 - ### Compiler 694 - 695 - - The displaying of internal types in HTML documentation has been improved. 696 - ([Louis Pilfold](https://github.com/lpil)) 697 - 698 - - A warning is now emitted when the same module is imported 699 - multiple times into the same module with different aliases. 700 - ([Louis Pilfold](https://github.com/lpil)) 701 - 702 - ### Bug fixes 703 - 704 - - Fixed a bug where a bit array segment matching on a floating point number 705 - would match with `NaN` or `Infinity` on the JavaScript target. 706 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
+706
changelog/v1.12.md
··· 1 + # Changelog 2 + 3 + ## v1.12.0 - 2025-08-05 4 + 5 + ### Bug fixes 6 + 7 + - Corrected an error message that used incorrect terminology. 8 + ([Louis Pilfold](https://github.com/lpil)) 9 + 10 + ## v1.12.0-rc3 - 2025-07-31 11 + 12 + ### Bug fixes 13 + 14 + - Fixed a bug where using `echo` in a module with a function named `process` 15 + would result in a runtime error on JavaScript. 16 + ([Peter Saxton](https://github.com/CrowdHailer)) 17 + 18 + ## v1.12.0-rc2 - 2025-07-24 19 + 20 + ### Formatter 21 + 22 + - The formatter now allows more control over how bit arrays are split. By adding 23 + a trailing comma at the end of a bit array that can fit on a single line, the 24 + bit array will be split on multiple lines: 25 + 26 + ```gleam 27 + pub fn dgram() -> BitArray { 28 + <<ip_version:4, header_length:4, service_type:8,>> 29 + } 30 + ``` 31 + 32 + Will be formatted as: 33 + 34 + ```gleam 35 + pub fn dgram() -> BitArray { 36 + << 37 + ip_version:4, 38 + header_length:4, 39 + service_type:8, 40 + >> 41 + } 42 + ``` 43 + 44 + By removing the trailing comma, the formatter will try and fit the bit array 45 + on a single line again: 46 + 47 + ```gleam 48 + pub fn dgram() -> BitArray { 49 + << 50 + ip_version:4, 51 + header_length:4, 52 + service_type:8 53 + >> 54 + } 55 + ``` 56 + 57 + Will be formatted back to a single line: 58 + 59 + ```gleam 60 + pub fn dgram() -> BitArray { 61 + <<ip_version:4, header_length:4, service_type:8>> 62 + } 63 + ``` 64 + 65 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 66 + 67 + - The formatter now allows more control over how bit arrays are formatted. 68 + If a bit array is split with multiple segments on the same line, removing the 69 + trailing comma will make sure the formatter keeps each segment on its own 70 + line: 71 + 72 + ```gleam 73 + pub fn dgram() -> BitArray { 74 + << 75 + "This bit array was formatted", "keeping segments on the same line", 76 + "notice how the formatting changes by removing the trailing comma ->", 77 + >> 78 + } 79 + ``` 80 + 81 + Is formatted as: 82 + 83 + ```gleam 84 + pub fn dgram() -> BitArray { 85 + << 86 + "This bit array was formatted", 87 + "keeping segments on the same line", 88 + "notice how the formatting changes by removing the trailing comma ->" 89 + >> 90 + } 91 + ``` 92 + 93 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 94 + 95 + ### Bug fixes 96 + 97 + - Fixed a bug where the formatter would move a comment before `assert` to be 98 + after it. 99 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 100 + 101 + - Fixed a bug where the message following an `echo`, `panic`, `todo`, `assert`, 102 + or `let assert` would not be formatted properly when preceded by a comment. 103 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 104 + 105 + - Fixed a bug where the compiler would generate invalid code for an `assert` 106 + using pipes on the JavaScript target. 107 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 108 + 109 + ## v1.12.0-rc1 - 2025-07-18 110 + 111 + ### Compiler 112 + 113 + - It is now possible to add a custom message to be printed by `echo`, making it 114 + easier to include additional context to be printed at runtime: 115 + 116 + ```gleam 117 + pub fn main() { 118 + echo 11 as "lucky number" 119 + } 120 + ``` 121 + 122 + Will output to stderr: 123 + 124 + ```txt 125 + /src/module.gleam:2 lucky number 126 + 11 127 + ``` 128 + 129 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 130 + 131 + - Generated JavaScript functions, constants, and custom type constructors now 132 + include any doc comment as a JSDoc comment, making it easier to use the 133 + generated code and browse its documentation from JavaScript. 134 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 135 + 136 + - The code generated for a `case` expression on the JavaScript target is now 137 + reduced in size in many cases. 138 + ([Surya Rose](https://github.com/GearsDatapacks)) 139 + 140 + - The code generators now perform usage-based dead code elimination. Unused 141 + definitions are not longer generated. 142 + ([Louis Pilfold](https://github.com/lpil)) 143 + 144 + - `echo` now has better support for character lists, JavaScript errors, and 145 + JavaScript circular references. 146 + ([Louis Pilfold](https://github.com/lpil)) 147 + 148 + - The look of errors and warnings has been improved. Additional labels providing 149 + context for the error message are no longer highlighted with the same style as 150 + the source of the problem. 151 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 152 + 153 + - Gleam will now emit a helpful message when attempting to import modules using 154 + `.` instead of `/`. 155 + 156 + ```txt 157 + error: Syntax error 158 + ┌─ /src/parse/error.gleam:1:11 159 + 160 + 1 │ import one.two.three 161 + │ ^ I was expecting either `/` or `.{` here. 162 + 163 + Perhaps you meant one of: 164 + 165 + import one/two 166 + import one.{item} 167 + ``` 168 + 169 + ([Zij-IT](https://github.com/zij-it)) 170 + 171 + - The compiler now emits a warning when a top-level constant or function 172 + declaration shadows an imported name in the current module. 173 + ([Aayush Tripathi](https://github.com/aayush-tripathi)) 174 + 175 + - The compiler can now tell when an unknown variable might be referring to an 176 + ignored variable and provide an helpful error message highlighting it. For 177 + example, this piece of code: 178 + 179 + ```gleam 180 + pub fn go() { 181 + let _x = 1 182 + x + 1 183 + } 184 + ``` 185 + 186 + Now results in the following error: 187 + 188 + ``` 189 + error: Unknown variable 190 + ┌─ /src/one/two.gleam:4:3 191 + 192 + 3 │ let _x = 1 193 + │ -- This value is discarded 194 + 4 │ x + 1 195 + │ ^ So it is not in scope here. 196 + 197 + Hint: Change `_x` to `x` or reference another variable 198 + ``` 199 + 200 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 201 + 202 + - The code generated for pattern matching has been optimised on the JavaScript 203 + target to reuse the matched variables when safe to do so. Take the following 204 + snippet of Gleam code: 205 + 206 + ```gleam 207 + pub fn find_book() { 208 + case ask_for_isbn() { 209 + Ok(isbn) -> load_book(isbn) 210 + Error(Nil) -> Error(Nil) 211 + } 212 + } 213 + ``` 214 + 215 + Notice how in the `Error` case we're returning exactly the same value that is 216 + being matched on! Now the compiler will generate the following JavaScript code 217 + instead of allocating a new `Error` variant entirely: 218 + 219 + ```js 220 + export function find_book() { 221 + let result = ask_for_isbn(); 222 + if (result instanceof Ok) { 223 + let isbn = result[0]; 224 + return load_book(isbn); 225 + } else { 226 + // Previously this would have been: `return new Error(undefined);`! 227 + return result; 228 + } 229 + } 230 + ``` 231 + 232 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 233 + 234 + - The compiler now raises a warning when performing a redundant comparison that 235 + it can tell is always going to succeed or fail. For example, this piece of 236 + code: 237 + 238 + ```gleam 239 + pub fn find_line(lines) { 240 + list.find(lines, fn(x) { x == x }) 241 + } 242 + ``` 243 + 244 + Would result in the following warning: 245 + 246 + ``` 247 + warning: Redundant comparison 248 + ┌─ /src/warning.gleam:2:17 249 + 250 + 1 │ list.find(lines, fn(x) { x == x }) 251 + │ ^^^^^^ This is always `True` 252 + 253 + This comparison is redundant since it always succeeds. 254 + ``` 255 + 256 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 257 + 258 + - Attempting to use the list prefix syntax with two lists will now 259 + show a helpful error message. For example, this snippet of code: 260 + 261 + ```gleam 262 + pub fn main() -> Nil { 263 + let xs = [1, 2, 3] 264 + let ys = [5, 6, 7] 265 + [1, ..xs, ..ys] 266 + } 267 + ``` 268 + 269 + Would result in the following error: 270 + 271 + ``` 272 + error: Syntax error 273 + ┌─ /src/parse/error.gleam:5:13 274 + 275 + 5 │ [1, ..xs, ..ys] 276 + │ -- ^^ I wasn't expecting a second list here 277 + │ │ 278 + │ You're using a list here 279 + 280 + Lists are immutable and singly-linked, so to join two or more lists 281 + all the elements of the lists would need to be copied into a new list. 282 + This would be slow, so there is no built-in syntax for it. 283 + ``` 284 + 285 + ([Carl Bordum Hansen](https://github.com/carlbordum)) and 286 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 287 + 288 + - The error message one gets when calling a function with the wrong number of 289 + arguments has been improved and now only suggests the relevant missing labels. 290 + For example, this piece of code: 291 + 292 + ```gleam 293 + pub type Pokemon { 294 + Pokemon(id: Int, name: String, moves: List(String)) 295 + } 296 + 297 + pub fn best_pokemon() { 298 + Pokemon(198, name: "murkrow") 299 + } 300 + ``` 301 + 302 + Would result in the following error, suggesting the missing labels: 303 + 304 + ```txt 305 + error: Incorrect arity 306 + ┌─ /src/main.gleam:6:3 307 + 308 + 6 │ Pokemon(198, name: "murkrow") 309 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expected 3 arguments, got 2 310 + 311 + This call accepts these additional labelled arguments: 312 + 313 + - moves 314 + ``` 315 + 316 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 317 + 318 + - Code generators now reuse existing variables when possible for the record 319 + update syntax, reducing the size of the generated code and number of 320 + variables defined for both Erlang and JavaScript. 321 + 322 + ```gleam 323 + pub fn main() -> Nil { 324 + let trainer = Trainer(name: "Ash", badges: 0) 325 + battle(Trainer(..trainer, badges: 1)) 326 + } 327 + ``` 328 + 329 + Previously this Gleam code would generate this Erlang code: 330 + 331 + ```erlang 332 + -spec main() -> nil. 333 + main() -> 334 + Trainer = {trainer, 0, <<"Ash"/utf8>>}, 335 + battle( 336 + begin 337 + _record = Trainer, 338 + {trainer, 1, erlang:element(3, _record)} 339 + end 340 + ). 341 + ``` 342 + 343 + Now this code will be generated instead: 344 + 345 + ```erlang 346 + -spec main() -> nil. 347 + main() -> 348 + Trainer = {trainer, 0, <<"Ash"/utf8>>}, 349 + battle({trainer, 1, erlang:element(3, Trainer)}). 350 + ``` 351 + 352 + ([Louis Pilfold](https://github.com/lpil)) 353 + 354 + - The compiler now allows using bit array options to specify endianness when 355 + constructing or pattern matching on UTF codepoints in bit arrays. 356 + ([Surya Rose](https://github.com/GearsDatapacks)) 357 + 358 + - Calculations are now allowed in the size options of bit array patterns. For 359 + example, the following code is now valid: 360 + 361 + ```gleam 362 + let assert <<size, data:bytes-size(size / 8 - 1)>> = some_bit_array 363 + ``` 364 + 365 + ([Surya Rose](https://github.com/GearsDatapacks)) 366 + 367 + - On the Erlang target each generated module enables inlining from the Erlang 368 + compiler. 369 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 370 + 371 + - The code generated for division and modulo operators on the JavaScript target 372 + has been improved to avoid performing needless checks. 373 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 374 + 375 + ### Build tool 376 + 377 + - `gleam update`, `gleam deps update`, and `gleam deps download` will now print 378 + a message when there are new major versions of packages available. For 379 + example: 380 + 381 + ```text 382 + $ gleam update 383 + Resolving versions 384 + 385 + The following dependencies have new major versions available: 386 + 387 + gleam_http 1.7.0 -> 4.0.0 388 + gleam_json 1.0.1 -> 3.0.1 389 + lustre 3.1.4 -> 5.1.1 390 + ``` 391 + 392 + ([Amjad Mohamed](https://github.com/andho)) 393 + 394 + - The documentation generator now strips trailing slashes from Gitea/Forgejo 395 + hosts so sidebar "Repository" and "View Source" links never include `//`, and 396 + single-line "View Source" anchors emit `#Lx` instead of `#Lx-x`. 397 + ([Aayush Tripathi](https://github.com/aayush-tripathi)) 398 + 399 + - The build tool can now compile packages that will have already booted the 400 + Erlang compiler application instead of failing. 401 + ([Louis Pilfold](https://github.com/lpil)) 402 + 403 + - `gleam deps list` now uses a tab rather than a space as a separator. 404 + ([Louis Pilfold](https://github.com/lpil)) 405 + 406 + - The build tool now also supports `.cjs` files placed in the `src`, `dev` or 407 + `test` directories. 408 + ([yoshi](https://github.com/yoshi-monster)) 409 + 410 + - The build tool now produces better error messages when version resolution 411 + fails. For example: 412 + 413 + ``` 414 + $ gleam add wisp@1 415 + Resolving versions 416 + error: Dependency resolution failed 417 + 418 + There's no compatible version of `gleam_otp`: 419 + - You require wisp >= 1.0.0 and < 2.0.0 420 + - wisp requires mist >= 1.2.0 and < 5.0.0 421 + - mist requires gleam_otp >= 0.9.0 and < 1.0.0 422 + - You require lustre >= 5.2.1 and < 6.0.0 423 + - lustre requires gleam_otp >= 1.0.0 and < 2.0.0 424 + 425 + There's no compatible version of `gleam_json`: 426 + - You require wisp >= 1.0.0 and < 2.0.0 427 + - wisp requires gleam_json >= 3.0.0 and < 4.0.0 428 + - You require gleam_json >= 2.3.0 and < 3.0.0 429 + ``` 430 + 431 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 432 + 433 + - The `repository` section in `gleam.toml` now allows specifying the 434 + `tag-prefix` property, which is prepended to the default tag. 435 + This makes it possible to have multiple packages with different versions in 436 + the same repository (together with `path`), without breaking links to source 437 + code in documentation. 438 + ([Sakari Bergen](https://github.com/sbergen)) 439 + 440 + ### Language server 441 + 442 + - It is now possible to use the "Pattern match on variable" code action on 443 + variables on the left hand side of a `use`. For example: 444 + 445 + ```gleam 446 + pub type User { 447 + User(id: Int, name: String) 448 + } 449 + 450 + pub fn main() { 451 + use user <- result.try(load_user()) 452 + // ^^^^ Triggering the code action here 453 + todo 454 + } 455 + ``` 456 + 457 + Would result in the following code: 458 + 459 + ```gleam 460 + pub type User { 461 + User(id: Int, name: String) 462 + } 463 + 464 + pub fn main() { 465 + use user <- result.try(load_user()) 466 + let User(id:, name:) = user 467 + todo 468 + } 469 + ``` 470 + 471 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 472 + 473 + - The "generate function" and "generate variant" code actions are now 474 + quickfixes, allowing them to be more easily applied to code which is producing 475 + an error. 476 + ([Surya Rose](https://github.com/GearsDatapacks)) 477 + 478 + - The language server now offers a code action to remove needless blocks 479 + wrapping a single expression. For example, in this code snippet: 480 + 481 + ```gleam 482 + case greeting { 483 + User(name:) -> { "Hello, " <> name } 484 + // ^^^^^^^^^^^^^^^^^^^^^ Triggering the code action 485 + // with the cursor over this block. 486 + Anonymous -> "Hello, stranger!" 487 + } 488 + ``` 489 + 490 + Would be turned into: 491 + 492 + ```gleam 493 + case greeting { 494 + User(name:) -> "Hello, " <> name 495 + Anonymous -> "Hello, stranger!" 496 + } 497 + ``` 498 + 499 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 500 + 501 + - It is now possible to trigger the "Add type annotation" code action anywhere 502 + between the start of a function definition and the start of its body. For 503 + example the action can trigger here while it previously wouldn't: 504 + 505 + ```gleam 506 + pub fn my_lucky_number() { 507 + // ^^ The action can trigger here as well! 508 + 11 509 + } 510 + ``` 511 + 512 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 513 + 514 + ### Formatter 515 + 516 + - The formatter now allows more control over how lists are split. By adding a 517 + trailing comma at the end of a list that can fit on a single line, the list 518 + will be split on multiple lines: 519 + 520 + ```gleam 521 + pub fn my_favourite_pokemon() -> List(String) { 522 + ["natu", "chimecho", "milotic",] 523 + } 524 + ``` 525 + 526 + Will be formatted as: 527 + 528 + ```gleam 529 + pub fn my_favourite_pokemon() -> List(String) { 530 + [ 531 + "natu", 532 + "chimecho", 533 + "milotic", 534 + ] 535 + } 536 + ``` 537 + 538 + By removing the trailing comma, the formatter will try and fit the list on a 539 + single line again: 540 + 541 + ```gleam 542 + pub fn my_favourite_pokemon() -> List(String) { 543 + [ 544 + "natu", 545 + "chimecho", 546 + "milotic" 547 + ] 548 + } 549 + ``` 550 + 551 + Will be formatted back to a single line: 552 + 553 + ```gleam 554 + pub fn my_favourite_pokemon() -> List(String) { 555 + ["natu", "chimecho", "milotic"] 556 + } 557 + ``` 558 + 559 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 560 + 561 + - The formatter now allows more control over how lists are formatted. 562 + If a list is split with multiple elements on the same line, removing the 563 + trailing comma will make sure the formatter keeps each item on its own line: 564 + 565 + ```gleam 566 + pub fn my_favourite_pokemon() -> List(String) { 567 + [ 568 + "This list was formatted", "keeping multiple elements on the same line", 569 + "notice how the formatting changes by removing the trailing comma ->" 570 + ] 571 + } 572 + ``` 573 + 574 + Is formatted as: 575 + 576 + ```gleam 577 + pub fn my_favourite_pokemon() -> List(String) { 578 + [ 579 + "This list was formatted", 580 + "keeping multiple elements on the same line", 581 + "notice how the formatting changes by removing the trailing comma ->", 582 + ] 583 + } 584 + ``` 585 + 586 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 587 + 588 + - The formatter no longer removes empty lines between list items. In case an 589 + empty line is added between list items they will all be split on multiple 590 + lines. For example: 591 + 592 + ```gleam 593 + pub fn main() { 594 + [ 595 + "natu", "xatu", 596 + 597 + "chimeco" 598 + ] 599 + } 600 + ``` 601 + 602 + Is formatted as: 603 + 604 + ```gleam 605 + pub fn main() { 606 + [ 607 + "natu", 608 + "xatu", 609 + 610 + "chimeco", 611 + ] 612 + } 613 + ``` 614 + 615 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 616 + 617 + ### Bug fixes 618 + 619 + - Fixed a bug where the language server would not show type-related code actions 620 + for record fields in custom type definitions. 621 + ([cysabi](https://github.com/cysabi)) 622 + 623 + - Fixed a bug where the "Inline variable" code action would be offered for 624 + function parameters and other invalid cases. 625 + ([Surya Rose](https://github.com/GearsDatapacks)) 626 + 627 + - Fixed a bug where the "Inline variable" code action would not be applied 628 + correctly to variables using label shorthand syntax. 629 + ([Surya Rose](https://github.com/GearsDatapacks)) 630 + 631 + - Fixed a bug where the compiler would emit the same error twice for patterns 632 + with the wrong number of labels. 633 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 634 + 635 + - Fixed a bug where the language server would generate invalid code when the 636 + "Extract variable" code action was used on a `use` expression. 637 + ([Surya Rose](https://github.com/GearsDatapacks)) 638 + 639 + - Fixed a bug where the compiler would crash when using the `utf8_codepoint` 640 + bit array segment on the JavaScript target. 641 + ([Surya Rose](https://github.com/GearsDatapacks)) 642 + 643 + - Fixed a bug where `==` and `!=` would return incorrect output for some 644 + JavaScript objects. 645 + ([Louis Pilfold](https://github.com/lpil)) 646 + 647 + - Fixed a bug where specific combinations of options in bit array segments would 648 + not be allowed on the JavaScript target. 649 + ([Surya Rose](https://github.com/GearsDatapacks)) 650 + 651 + - Fixed a bug where invalid code would be generated for `let assert` in some 652 + cases on the JavaScript target. 653 + ([Surya Rose](https://github.com/GearsDatapacks)) 654 + 655 + - Fixed a bug where using the prelude `Ok` and `Error` values in a qualified 656 + fashion could cause a conflict with user-defined `Ok` and `Error` values when 657 + generating code on the JavaScript target. 658 + ([Surya Rose](https://github.com/GearsDatapacks)) 659 + 660 + - Fixed a bug where the "Import module" code action would suggest importing 661 + internal modules from other packages. 662 + ([Surya Rose](https://github.com/GearsDatapacks)) 663 + 664 + - Fixed a bug where the language server would not rename variables defined in 665 + alternative patterns. 666 + ([Surya Rose](https://github.com/GearsDatapacks)) 667 + 668 + - Fixed a bug where trying to rename a type or value from the Gleam prelude 669 + would result in invalid code. 670 + ([Surya Rose](https://github.com/GearsDatapacks)) 671 + 672 + - Fixed a bug where the generated documentation would not be formatted properly. 673 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 674 + 675 + - Fixed a bug where the language server wouldn't allow you to jump to the 676 + definition of a record from a record update expression. 677 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 678 + 679 + - Fixed a bug where the language server would allow using the "extract variable" 680 + code action on variables used in record updates. 681 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 682 + 683 + - Fixed a bug where a record pattern with a spread `..` would not be formatted 684 + properly. 685 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 686 + 687 + - Fixed a bug where fields of custom types named `prototype` would not be 688 + properly escaped on the JavaScript target. 689 + ([Surya Rose](https://github.com/GearsDatapacks)) 690 + 691 + ## v1.11.1 - 2025-06-05 692 + 693 + ### Compiler 694 + 695 + - The displaying of internal types in HTML documentation has been improved. 696 + ([Louis Pilfold](https://github.com/lpil)) 697 + 698 + - A warning is now emitted when the same module is imported 699 + multiple times into the same module with different aliases. 700 + ([Louis Pilfold](https://github.com/lpil)) 701 + 702 + ### Bug fixes 703 + 704 + - Fixed a bug where a bit array segment matching on a floating point number 705 + would match with `NaN` or `Infinity` on the JavaScript target. 706 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri))