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

Configure Feed

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

1<!-- 2 SPDX-License-Identifier: Apache-2.0 3 SPDX-FileCopyrightText: 2020 The Gleam contributors 4--> 5 6# Changelog 7 8## v1.11.0 - 2025-06-02 9 10### Bug fixes 11 12- Fixed a bug where using a pipe operator on the right-hand side of an `assert` 13 statement would generate invalid code on the JavaScript target. 14 ([Surya Rose](https://github.com/GearsDatapacks)) 15 16- Fixed a bug where the build tool would try to run a module whose main 17 function is private. 18 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 19 20- Fixed a bug where the compiler would sometimes warn that an assertion was 21 unnecessary because it only asserted literal values, when that was not the case. 22 ([Surya Rose](https://github.com/GearsDatapacks)) 23 24- Fixed a bug where using the "generate function" code action on a function 25 capture would generate an argument named `_capture`, using the internal 26 variable names of the compiler. 27 ([Surya Rose](https://github.com/GearsDatapacks)) 28 29- Fixed a bug where the language server would provide completions inside a 30 constant string. 31 ([Surya Rose](https://github.com/GearsDatapacks)) 32 33- Fixed a grammatical error in the bit array truncation warning message. 34 ([Louis Pilfold](https://github.com/lpil)) 35 36## v1.11.0-rc2 - 2025-05-29 37 38### Compiler 39 40- The format of the `assert` and `let assert` location information has been 41 improved, and the file path of the source module has been added. 42 ([Louis Pilfold](https://github.com/lpil)) 43 44### Language server 45 46- When using the "remove `echo`" code action, the language server will also 47 remove any literal expression being printed by `echo` statements. For example 48 49 ```gleam 50 pub fn main() { 51 echo "Before" 52 do_complex_stuff() 53 echo "After" 54 do_something_else() 55 } 56 ``` 57 58 Will become: 59 60 ```gleam 61 pub fn main() { 62 do_complex_stuff() 63 do_something_else() 64 } 65 ``` 66 67 Making it easier to get rid of debug printing messages once they're no longer 68 needed. 69 70 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 71 72### Bug fixes 73 74- Fixed a bug where type constructors with many fields would not be formatted 75 properly in the generated documentation. 76 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 77 78- Fixed a bug where fields name `x0` in records could cause invalid code to be 79 generated on the JavaScript target. 80 ([Surya Rose](https://github.com/GearsDatapacks)) 81 82- Fixed a bug where exceptions on JavaScript could be sometimes missing the 83 function name metadata. 84 ([Louis Pilfold](https://github.com/lpil)) 85 86- Fixed a bug where the missing patterns shown for an inexhaustive `case` 87 expression would include constructors of opaque types which were not available 88 in the current module, leading to invalid code. 89 ([Surya Rose](https://github.com/GearsDatapacks)) 90 91- Fixed a bug where the language server would offer completions for local 92 variables where the variables were not in scope, leading to invalid code being 93 produced if the completion was followed. 94 ([Surya Rose](https://github.com/GearsDatapacks)) 95 96- Fixed a bug where the compiler would crash when compiling `let assert` 97 statements which contained a bit array pattern inside a tuple pattern on the 98 JavaScript target. 99 ([Surya Rose](https://github.com/GearsDatapacks)) 100 101- Fixed a bug where a zero-length segment of a bit array would never match 102 in a case expression on the JavaScript target. 103 ([Sakari Bergen](https://github.com/sbergen)) 104 105## v1.11.0-rc1 - 2025-05-15 106 107### Compiler 108 109- The compiler can now tell if some branches with bit array patterns are 110 unreachable. For example, the following code: 111 112 ```gleam 113 case payload { 114 <<first_byte, _:bits>> -> first_byte 115 <<1, _:bits>> -> 1 116 _ -> 0 117 } 118 ``` 119 120 Will raise the following warning: 121 122 ``` 123 warning: Unreachable case clause 124 ┌─ /src/bit_array.gleam:4:5 125126 4 │ <<1, _:bits>> -> 1 127 │ ^^^^^^^^^^^^^^^^^^ 128 This case clause cannot be reached as a previous clause matches the same 129 values. 130 Hint: It can be safely removed. 131 ``` 132 133 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 134 135- The code generated for pattern matching on the JavaScript target has been 136 improved to be more efficient and perform as little checks as possible. 137 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 138 139- The compiler now raises a warning when it can tell that an int segment 140 with a literal value is going to be truncated. For example, if you wrote this: 141 142 ```gleam 143 <<258>> 144 ``` 145 146 The compiler will now warn you: 147 148 ```txt 149 warning: Truncated bit array segment 150 ┌─ /src/main.gleam:4:5 151152 4 │ <<258>> 153 │ ^^^ You can safely replace this with 2 154 155 This segment is 1 byte long, but 258 doesn't fit in that many bytes. It 156 would be truncated by taking its first byte, resulting in the value 2. 157 ``` 158 159 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 160 161- The compiler will now include labels in the error message when a `case` 162 expression is inexhaustive. For example, this code: 163 164 ```gleam 165 pub type Person { 166 Person(name: String, age: Int) 167 } 168 169 pub fn classify(person: Person) { 170 case person { 171 Person(name: "John", age: 27) -> todo 172 Person(name: _, age: 42) -> todo 173 } 174 } 175 ``` 176 177 Will produces this error: 178 179 ``` 180 error: Inexhaustive patterns 181 ┌─ /src/main.gleam:6:3 182183 6 │ ╭ case person { 184 7 │ │ Person(name: "John", age: 27) -> todo 185 8 │ │ Person(name: _, age: 42) -> todo 186 9 │ │ } 187 │ ╰───^ 188 189 This case expression does not have a pattern for all possible values. If it 190 is run on one of the values without a pattern then it will crash. 191 192 The missing patterns are: 193 194 Person(name:, age:) 195 ``` 196 197 ([Surya Rose](https://github.com/GearsDatapacks)) 198 199- The analysis of lists, tuples, negation operators, `panic`, `echo` and `todo` 200 is now fault tolerant, meaning that the compiler will not stop reporting 201 errors as soon as it finds one. 202 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 203 204- The error message for types used with the wrong number of arguments has been 205 improved. For example, this piece of code: 206 207 ```gleam 208 type Wibble(a) 209 210 type Wobble { 211 Wobble(Wibble) 212 } 213 ``` 214 215 Produces the following error: 216 217 ```txt 218 error: Incorrect arity 219 ┌─ /src/one/two.gleam:5:10 220221 5 │ Wobble(Wibble) 222 │ ^^^^^^ Expected 1 type argument, got 0 223 224 `Wibble` requires 1 type argument but none where provided. 225 ``` 226 227 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 228 229- You can now use the `assert` keyword by itself to test a boolean expression. 230 If the expression evaluates to `False` at runtime, the `assert` statement 231 will cause the program to panic, with information about the expression that 232 was asserted. 233 234 For example: 235 236 ```gleam 237 pub fn ok_error_test() { 238 assert result.is_ok(Ok(10)) 239 assert result.is_error(Error("Some error")) 240 assert Ok(1) != Error(1) 241 assert result.is_error(Ok(42)) // panic: Assertion failed 242 } 243 ``` 244 245 A custom panic message can also be provided in order to add extra information: 246 247 ```gleam 248 pub fn identity_test() { 249 assert function.identity(True) as "Identity of True should never be False" 250 } 251 ``` 252 253 ([Surya Rose](https://github.com/GearsDatapacks)) 254 255- The compiler will now emit a warning when the return value of a call to a 256 function without side effects is unused. For example the following code: 257 258 ```gleam 259 pub fn main() { 260 add(1, 2) 261 add(3, 4) 262 } 263 ``` 264 265 Will produce the following warning: 266 267 ``` 268 warning: Unused value 269 ┌─ /src/main.gleam:4:3 270271 4 │ add(1, 2) 272 │ ^^^^^^^^^ This value is never used 273 274 This expression computes a value without any side effects, but then the 275 value isn't used at all. You might want to assign it to a variable, or 276 delete the expression entirely if it's not needed. 277 ``` 278 279 ([Surya Rose](https://github.com/GearsDatapacks)) 280 281- The compiler will now generate more efficient code for `let assert` on the 282 Erlang target. 283 ([Surya Rose](https://github.com/GearsDatapacks)) 284 285- The compiler will now reject bit array segment patterns whose constant size is 286 zero or negative. Previously a zero or negative sized segment would crash the 287 compiler. 288 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 289 290- The compiler will not generate needless code for unused pattern variables. 291 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 292 293- Function parameters are now fault tolerant, meaning that type-checking can 294 continue to occur if a function references invalid type in its signature. 295 ([Surya Rose](https://github.com/GearsDatapacks)) 296 297- The compiler is now fault tolerant when analysing patterns for custom types, 298 meaning it won't stop at the first error it encounters (for example if a 299 constructor is wrong). 300 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 301 302- On the JavaScript target, bit arrays now support UTf-16 and UTF-32 string 303 segments. 304 ([Surya Rose](https://github.com/GearsDatapacks)) 305 306- When an import with unqualified types and values is unused the compiler will 307 now raise a single warning for the entire import rather than warning for each 308 individual item. 309 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 310 311### Build tool 312 313- The build tool now supports placing modules in a directory called `dev`, 314 which like `test`, is only for development code. 315 ([Surya Rose](https://github.com/GearsDatapacks)) 316 317- There is now a new CLI command, `gleam dev`, which runs the `$PACKAGE_dev` 318 module, for running development entrypoints. 319 ([Surya Rose](https://github.com/GearsDatapacks)) 320 321- Updated the Erlang shipment POSIX entrypoint script to add an exec statement 322 so the Erlang process replaces the shell's process and can receive signals 323 when deployed. 324 ([Christopher De Vries](https://github.com/devries)) 325 326- The build tool now provides additional information when printing warnings for 327 deprecated environment variables. 328 ([Surya Rose](https://github.com/GearsDatapacks)) 329 330- When generating documentation, the build tool now prints type variable using 331 the same names as were used in the code for function signatures. For example, 332 this code: 333 334 ```gleam 335 pub fn from_list(entries: List(#(key, value))) -> Dict(key, value) { 336 ... 337 } 338 ``` 339 340 Previously would have been printed as: 341 342 ```gleam 343 pub fn from_list(entries: List(#(a, b))) -> Dict(a, b) 344 ``` 345 346 But now is rendered as the following: 347 348 ```gleam 349 pub fn from_list(entries: List(#(key, value))) -> Dict(key, value) 350 ``` 351 352 ([Surya Rose](https://github.com/GearsDatapacks)) 353 354- When generating documentation, types from other modules are now rendered with 355 their module qualifiers. Hovering over them shows the module name. 356 For example, this code: 357 358 ```gleam 359 import gleam/dynamic/decode 360 361 pub fn something_decoder() -> decode.Decoder(Something) { 362 ... 363 } 364 ``` 365 366 Will now generate the following documentation: 367 368 ```gleam 369 pub fn something_decoder() -> decode.Decoder(Something) 370 ``` 371 372 And hovering over the `decode.Decoder` text will show the following: 373 374 ```txt 375 gleam/dynamic/decode.{type Decoder} 376 ``` 377 378 ([Surya Rose](https://github.com/GearsDatapacks)) 379 380- When generating documentation, types in rendered documentation code will now 381 link to their corresponding documentation pages. 382 ([Surya Rose](https://github.com/GearsDatapacks)) 383 384- `gleam add` will now emit an error if you try to add a package as a dependency 385 of itself. 386 ([Louis Pilfold](https://github.com/lpil)) 387 388- The build tool will now emit an error when compiling a package if the package 389 has a Gleam and Erlang file which would collide. 390 ([Surya Rose](https://github.com/GearsDatapacks)) 391 392### Language server 393 394- The code action to add missing labels to functions now also works in patterns: 395 396 ```gleam 397 pub type Person { 398 Person(name: String, age: Int, job: String) 399 } 400 401 pub fn age(person: Person) { 402 let Person(age:) = person 403 age 404 } 405 ``` 406 407 Becomes: 408 409 ```gleam 410 pub type Person { 411 Person(name: String, age: Int, job: String) 412 } 413 414 pub fn age(person: Person) { 415 let Person(age:, name:, job:) = person 416 age 417 } 418 ``` 419 420 ([Surya Rose](https://github.com/GearsDatapacks)) 421 422- The JSON encoding function that the language server code action generates is 423 now named `$TYPENAME_to_json` instead of `encode_$TYPENAME`. This is to remove 424 ambiguity with functions that encode to other formats, and to make the 425 function easier to discover by searching. 426 ([Louis Pilfold](https://github.com/lpil)) 427 428- The code action to add missing patterns to a `case` expression now includes 429 labels in the generated patterns. For example: 430 431 ```gleam 432 pub type Person { 433 Person(name: String, age: Int) 434 } 435 436 pub fn classify(person: Person) { 437 case person { 438 Person(name: "John", age: 27) -> todo 439 Person(name: _, age: 42) -> todo 440 } 441 } 442 ``` 443 444 Will now become: 445 446 ```gleam 447 pub type Person { 448 Person(name: String, age: Int) 449 } 450 451 pub fn classify(person: Person) { 452 case person { 453 Person(name: "John", age: 27) -> todo 454 Person(name: _, age: 42) -> todo 455 Person(name:, age:) -> todo 456 } 457 } 458 ``` 459 460 ([Surya Rose](https://github.com/GearsDatapacks)) 461 462- The language server now provides hover, autocomplete and goto definition 463 for constant definitions. 464 ([Surya Rose](https://github.com/GearsDatapacks)) 465 466- The "generate function" code action can now choose better names based on the 467 labels and variables used. For example if I write the following code: 468 469 ```gleam 470 pub fn main() -> List(Int) { 471 let list = [1, 2, 3] 472 let number = 1 473 remove(each: number, in: list) 474 //^^^^ This function doesn't exist yet! 475 } 476 ``` 477 478 And ask the language server to generate the missing function, the generated 479 code will now look like this: 480 481 ```gleam 482 fn remove(each number: Int, in list: List(Int)) -> List(Int) { 483 todo 484 } 485 ``` 486 487 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 488 489- The language server now provides autocomplete suggestions for labels after 490 part of the label has already been typed. For example, in this code: 491 492 ```gleam 493 pub type Person { 494 Person(name: String, number: Int) 495 } 496 497 pub fn main() { 498 Person(n|) 499 } 500 ``` 501 502 The language server will provide `name:` and `number:` as autocomplete 503 suggestions. 504 505 ([Surya Rose](https://github.com/GearsDatapacks)) 506 507- The language server now provides a code action to automatically generate a new 508 variant from incorrect code: 509 510 ```gleam 511 pub type Msg { 512 ServerSentResponse(Json) 513 } 514 515 pub fn view() -> Element(Msg) { 516 div([], [ 517 button([on_click(UserPressedButton)], [text("Press me!")]) 518 // ^^^^^^^^^^^^^^^^^ This doesn't exist yet! 519 ]) 520 } 521 ``` 522 523 Triggering the code action on the `UserPressedButton` will add it to the `Msg` 524 type: 525 526 ```gleam 527 pub type Msg { 528 ServerSentResponse(Json) 529 UserPressedButton 530 } 531 ``` 532 533 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 534 535- The language server can now remove unused imported values and types: 536 537 ```gleam 538 import a_module.{type Unused, unused, used} 539 540 pub fn main() { 541 used 542 } 543 ``` 544 545 Triggering the code action will remove all unused types and values: 546 547 ```gleam 548 import a_module.{used} 549 550 pub fn main() { 551 used 552 } 553 ``` 554 555 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 556 557### Formatter 558 559- Improved the formatting of `echo` when followed by long binary expressions. 560 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 561 562### Installation 563 564- Windows ARM64 pre-built binaries are now provided. 565 ([Jonatan Männchen](https://github.com/maennchen)) 566 567### Bug fixes 568 569- Fixed a bug where `case` expressions in custom panic messages would compile 570 to invalid syntax on the JavaScript target. 571 ([Surya Rose](https://github.com/GearsDatapacks)) 572 573- Fixed a bug where an underscore after a zero in a number would compile to 574 invalid syntax on the JavaScript target. 575 ([Surya Rose](https://github.com/GearsDatapacks)) 576 577- Fixed a bug where the "generate function" code action could generate invalid 578 code when the same variable was passed as an argument twice. 579 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 580 581- Fixed a bug where replacing a Hex dependency with a Git dependency of the 582 same name would cause the build tool to fail. 583 ([Surya Rose](https://github.com/GearsDatapacks)) 584 585- Fixed a bug where updating the remote URL of a Git dependency would fail to 586 update the remote in the local dependency, causing a caching issue. 587 ([Surya Rose](https://github.com/GearsDatapacks)) 588 589- Fix slightly wrong error message for missing main function in test module. 590 ([Samuel Cristobal](https://github.com/scristobal)) 591 592- Fixed a bug where the compiler would not properly warn for unreachable 593 patterns in a `case` expression when the clause matched on multiple 594 alternative patterns. 595 ([Surya Rose](https://github.com/GearsDatapacks)) 596 597- Fixed a bug where the language server would generate invalid code for the 598 "fill in missing labels" code action. 599 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 600 601- Fixed a bug where referencing an earlier segment of the bit array in a bit 602 array pattern in a `let assert` assignment would generate invalid code on the 603 Erlang target. 604 ([Surya Rose](https://github.com/GearsDatapacks)) 605 606- Fixed instances where the "Extract variable" code action would produce invalid 607 code, most noticeable in code inside `case` clauses and `use` expressions. 608 ([Matias Carlander](https://github.com/matiascr)) 609 610- Fixed a bug where the compiler would crash when type-checking code containing 611 an assignment pattern inside a bit-array pattern. 612 ([Surya Rose](https://github.com/GearsDatapacks)) 613 614- Fixed a bug where using the pipe operator in the `size` option of a bit array 615 segment would generate invalid code on the Erlang target. 616 ([Surya Rose](https://github.com/GearsDatapacks)) 617 618- Fixed a bug where the language server would generate invalid code for the 619 "convert to use" code action, when used on a function call with labelled 620 arguments. 621 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 622 623- Fixed a bug where a reference to an imported external function with a 624 non-alphanumeric module name would compile to invalid syntax on the Erlang 625 target. 626 ([Mathieu Darse](https://github.com/mdarse)) 627 628- Fixed a bug where the compiler would not correctly check the size of bit 629 arrays when doing bit array pattern matching on the JavaScript target. 630 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 631 632- Fixed a bug where using the pipe operator inside a record update would cause 633 the compiler to generate invalid code on the JavaScript target. 634 ([Surya Rose](https://github.com/GearsDatapacks)) 635 636- Fixed a bug where some code actions would produce invalid code when a file 637 contained characters that were represented with more than one byte in UTF-8. 638 ([Surya Rose](https://github.com/GearsDatapacks)) 639 640- Fixed a bug where LSP ranges would be incorrect when a file contained characters 641 that were represented with more than one byte in UTF-8. 642 ([Surya Rose](https://github.com/GearsDatapacks)) 643 644- Only print the user-friendly LSP message when stdin is a terminal to avoid 645 emitting redundant logs. 646 ([Ariel Parker](https://github.com/arielherself)) 647 648- Fixed a bug where the language server would wrongly override local variables 649 if they were shadowing an unqualified module function. 650 ([Samuel Cristobal](https://github.com/scristobal)) 651 652- Fixed a bug where renaming a local variable which is used in combination with 653 label shorthand syntax would produce invalid code. 654 ([Surya Rose](https://github.com/GearsDatapacks)) 655 656- Fixed a bug where the stack would overflow on Windows when type-checking 657 multiple nested `use` expressions. 658 ([Surya Rose](https://github.com/GearsDatapacks)) 659 660- Fixed a bug where using a variable from a separate pattern inside a bit array 661 pattern would be allowed but generate invalid Erlang code. 662 ([Surya Rose](https://github.com/GearsDatapacks)) 663 664- Fixed a bug where the compiler would crash if duplicate variables were defined 665 in alternative patterns. 666 ([Surya Rose](https://github.com/GearsDatapacks))