Fork of daniellemaywood.uk/gleam — Wasm codegen work
1<!--
2 SPDX-License-Identifier: Apache-2.0
3 SPDX-FileCopyrightText: 2020 The Gleam contributors
4-->
5
6# Changelog
7
8## 1.7.0 - 2025-01-05
9
10Happy birthday Louis! 🎁
11
12## 1.7.0-rc3 - 2025-01-02
13
14### Formatter
15
16- Function captures are now formatted like regular function calls.
17 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
18
19- Record updates are now formatted like function calls.
20 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
21
22### Bug fixes
23
24- Fixed a bug where the "convert from use" code action would generate invalid
25 code with labelled arguments.
26 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
27
28- Fixed a bug where private types would be allowed to be used in other modules.
29 ([Surya Rose](https://github.com/GearsDatapacks))
30
31## 1.7.0-rc2 - 2024-12-30
32
33### Bug fixes
34
35- Fixed a bug on JavaScript where a trailing `:bytes` segment would give the
36 wrong pattern match result for a sliced bit array.
37 ([Richard Viney](https://github.com/richard-viney))
38
39## 1.7.0-rc1 - 2024-12-29
40
41### Compiler
42
43- Removed compiler hint about pattern matching a `Result(a, b)` when being used
44 where `a` is expected.
45 ([Kieran O'Reilly](https://github.com/SoTeKie))
46
47- Optimised code generated for record updates.
48 ([yoshi](https://github.com/joshi-monster))
49
50- The compiler now allows for record updates to change the generic type
51 parameters of the record:
52
53 ```gleam
54 type Box(value) {
55 Box(password: String, value: value)
56 }
57
58 fn insert(box: Box(a), value: b) -> Box(b) {
59 Box(..box, value:)
60 }
61 ```
62
63 ([yoshi](https://github.com/joshi-monster))
64
65- It is now allowed to write a block with no expressions. Like an empty function
66 body, an empty block is considered incomplete as if it contained a `todo`
67 expression.
68 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
69
70- The shorthand names for the two targets, `erl` and `js` are now
71 deprecated in code such as `@target`.
72 ([Surya Rose](https://github.com/GearsDatapacks))
73
74- A custom panic message can now be specified when asserting a value with
75 `let assert`:
76
77 ```gleam
78 let assert Ok(regex) = regex.compile("ab?c+") as "This regex is always valid"
79 ```
80
81 ([Surya Rose](https://github.com/GearsDatapacks))
82
83- When targeting JavaScript the compiler now generates faster and smaller code
84 for `Int` values in bit array expressions and patterns by evaluating them at
85 compile time where possible.
86 ([Richard Viney](https://github.com/richard-viney))
87
88- Qualified records can now be used in clause guards.
89 ([Surya Rose](https://github.com/GearsDatapacks))
90
91- The compiler now allows deprecating specific custom type variants using the
92 `@deprecated` attribute:
93
94 ```gleam
95 pub type HashAlgorithm {
96 @deprecated("Please upgrade to another algorithm")
97 Md5
98 Sha224
99 Sha512
100 }
101
102 pub fn hash_password(input: String) -> String {
103 hash(input:, algorithm: Md5) // Warning: Deprecated value used
104 }
105 ```
106
107 ([Iesha](https://github.com/wilbert-mad))
108
109- On the JavaScript target, taking byte-aligned slices of bit arrays is now an
110 O(1) operation instead of O(N), significantly improving performance.
111 ([Richard Viney](https://github.com/richard-viney))
112
113- Better error message for when an existing type constructor is used as a value
114 constructor.
115 ([Jiangda Wang](https://github.com/Frank-III))
116
117- Print better error messages when shell commands used by compiler cannot be
118 found.
119 ([wheatfox](https://github.com/enkerewpo))
120
121### Build tool
122
123- Improved the error message you get when trying to add a package that doesn't
124 exist with `gleam add`.
125 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
126
127- External files (such as `.mjs` and `.erl`) are now permitted in subdirectories
128 of `src/` and `test/`.
129 ([PgBiel](https://github.com/PgBiel))
130
131- `gleam publish` now requires more verbose confirmation for publishing Gleam
132 team packages and v0 packages.
133 ([Louis Pilfold](https://github.com/lpil))
134
135- `gleam publish` now warns when publishing packages that define multiple
136 top-level modules, as this can lead to namespace pollution and conflicts for
137 consumers.
138 ([Aleksei Gurianov](https://github.com/guria))
139
140- New projects now require `gleam_stdlib` v0.44.0.
141 ([Louis Pilfold](https://github.com/lpil))
142
143- `gleam remove` no longer requires a network connection.
144 ([yoshi](https://github.com/joshi-monster))
145
146- Commands that work with the Hex package manager API now create and store an
147 API key rather than creating a new one each time. This API key is encrypted
148 with a local password, reducing risk of your Hex password being compromised.
149 ([Louis Pilfold](https://github.com/lpil))
150
151- The build tool now sets the `REBAR_SKIP_PROJECT_PLUGINS` environment variable
152 when using rebar3 to compile Erlang dependencies. With future versions of
153 rebar3 this will cause it to skip project plugins, significantly reducing the
154 amount of code it'll need to download and compile, improving compile times.
155 ([Tristan Sloughter](https://github.com/tsloughter))
156
157### Language server
158
159- The language server now provides type information when hovering over argument
160 labels.
161 ([Surya Rose](https://github.com/GearsDatapacks))
162
163- The language server now suggests a code action to desugar a use expression
164 into the equivalent function call. For example, this snippet of code:
165
166 ```gleam
167 pub fn main() {
168 use profile <- result.try(fetch_profile(user))
169 render_welcome(user, profile)
170 }
171 ```
172
173 Will be turned into:
174
175 ```gleam
176 pub fn main() {
177 result.try(fetch_profile(user), fn(profile) {
178 render_welcome(user, profile)
179 })
180 }
181 ```
182
183 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
184
185- The language server now suggests a code action to turn a function call into
186 the equivalent use expression. For example, this snippet of code:
187
188 ```gleam
189 pub fn main() {
190 result.try(fetch_profile(user) fn(profile) {
191 render_welcome(user, profile)
192 })
193 }
194 ```
195
196 Will be turned into:
197
198 ```gleam
199 pub fn main() {
200 use profile <- result.try(fetch_profile(user))
201 render_welcome(user, profile)
202 }
203 ```
204
205 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
206
207- The language server now provides correct information when hovering over
208 patterns in use expressions.
209 ([Surya Rose](https://github.com/GearsDatapacks))
210
211- The language server now suggests a code action to convert an inexhaustive
212 `let` assignment into a `case` expression:
213
214 ```gleam
215 pub fn unwrap_result(result: Result(a, b)) -> a {
216 let Ok(inner) = result
217 inner
218 }
219 ```
220
221 Becomes:
222
223 ```gleam
224 pub fn unwrap_result(result: Result(a, b)) -> a {
225 let inner = case result {
226 Ok(inner) -> inner
227 Error(_) -> todo
228 }
229 inner
230 }
231 ```
232
233 ([Surya Rose](https://github.com/GearsDatapacks))
234
235- The language server now provides an action to extract a value into a variable.
236 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
237
238- The language server now suggests a code action to expand a function capture
239 into the equivalent anonymous function. For example, this snippet of code:
240
241 ```gleam
242 pub fn main() {
243 list.map([1, 2, 3], int.add(_, 11))
244 }
245 ```
246
247 Will be turned into:
248
249 ```gleam
250 pub fn main() {
251 list.map([1, 2, 3], fn(value) { int.add(value, 11) })
252 }
253 ```
254
255 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
256
257- The language server now suggests a code action to generate a dynamic decoder
258 for a custom type. For example, this code:
259
260 ```gleam
261 pub type Person {
262 Person(name: String, age: Int)
263 }
264 ```
265
266 Will become:
267
268 ```gleam
269 import gleam/dynamic/decode
270
271 pub type Person {
272 Person(name: String, age: Int)
273 }
274
275 fn person_decoder() -> decode.Decoder(Person) {
276 use name <- decode.field("name", decode.string)
277 use age <- decode.field("age", decode.int)
278 decode.success(Person(name:, age:))
279 }
280 ```
281
282 ([Surya Rose](https://github.com/GearsDatapacks))
283
284### Formatter
285
286- The formatter now adds a `todo` inside empty blocks.
287 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
288
289- The formatter now formats lists the same in constants as in expressions.
290 ([Jiangda Wang](https://github.com/Frank-III))
291
292### Documentation
293
294- Canonical links created for documentation pages if published on Hex.
295 Previously published documentation would need to be updated.
296 Resolves versioned pages to point to latest page for search engines.
297 ([Dave Lage](https://github.com/rockerBOO))
298
299### Bug fixes
300
301- The compiler now throws an error when a float literal ends with an `e` and
302 is missing an exponent.
303 ([Surya Rose](https://github.com/GearsDatapacks))
304
305- Fixed a crash with ENOTEMPTY (os error 39) when building on NTFS partitions.
306 ([Ivan Ermakov](https://github.com/ivanjermakov))
307
308- Fixed a bug where the compiler would crash when pattern matching on multiple
309 subjects and one of them being a constant record.
310 ([Surya Rose](https://github.com/GearsDatapacks))
311
312- Variant inference on prelude types now works correctly if the variant is
313 constant.
314 ([Surya Rose](https://github.com/GearsDatapacks))
315
316- Fixed a bug where patterns in `use` expressions would not be checked to ensure
317 that they were exhaustive.
318 ([Surya Rose](https://github.com/GearsDatapacks))
319
320- Fixed a bug where a `module.mjs` file would be overwritten by a `module.gleam`
321 file of same name without warning. It now produces an error.
322 ([PgBiel](https://github.com/PgBiel))
323
324- Modules depending on removed or renamed modules now get automatically
325 recompiled.
326 ([Sakari Bergen](https://github.com/sbergen))
327
328- The compiler now raises a warning for unused case expressions, code blocks and
329 pipelines that would be safe to remove.
330 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
331
332- Fixed a bug where assigning the prefix of a string pattern to a variable
333 nested inside another pattern would produce invalid code on Javascript.
334 ([yoshi](https://github.com/joshi-monster))
335
336- Fixed a bug where expressions which use an unsafe integer on JavaScript would
337 not emit a warning if an external function had been referenced.
338 ([Richard Viney](https://github.com/richard-viney))
339
340- Fixed a bug where nested tuple access would not be parsed correctly when
341 the left-hand side was a function call.
342 ([Surya Rose](https://github.com/GearsDatapacks))
343
344- Fixed a bug where Gleam would be unable to compile to BEAM bytecode on older
345 versions of Erlang/OTP.
346 ([yoshi](https://github.com/joshi-monster))
347
348- Fixed a bug where the inferred variant of values was not properly cached,
349 leading to incorrect errors on incremental builds and in the language server.
350 ([Surya Rose](https://github.com/GearsDatapacks))
351
352- Fixed a bug where Gleam would be unable to compile to BEAM bytecode if the
353 project path contains a non-ascii character.
354 ([yoshi](https://github.com/joshi-monster))
355
356- Fixed a bug where the compiler would display incorrect hints about ignoring
357 unused variables in certain cases.
358 ([Surya Rose](https://github.com/GearsDatapacks))
359
360- Fixed a bug where the completer would not include braces in type import
361 completions when it should have.
362 ([Jiangda Wang](https://github.com/Frank-III))
363
364- Fixed a bug where `gleam new` would generate the github `test` workflow
365 configuration with incompatible Erlang OTP and Elixir versions.
366 ([John Strunk](https://github.com/jrstrunk))
367
368## v1.6.1 - 2024-11-19
369
370### Bug fixes
371
372- Fixed a bug where `gleam update` would fail to update versions.
373 ([Jason Sipula](https://github.com/SnakeDoc))