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## v1.5.0 - 2024-09-19
9
10## v1.5.0-rc2 - 2024-09-18
11
12### Bug Fixes
13
14- Fixed a bug where the formatter would not format nested tuple access properly.
15 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
16
17- Fixed a bug where multi-variant custom type accessors wouldn't be properly
18 detected.
19 ([Louis Pilfold](https://github.com/lpil))
20
21
22## v1.5.0-rc1 - 2024-09-14
23
24### Build tool
25
26- The `--no-print-progress` flag has been added to prevent the build tool from
27 printing messages as the project is built.
28 ([Ankit Goel](https://github.com/crazymerlyn))
29
30- The compiler is now able to run a dependency's module using `gleam run -m`
31 even when there's compilation errors in your own project's code.
32 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
33
34- HTML docs: make module names in sidebar wrap before a / when possible
35 ([Jiangda Wang](https://github.com/frank-iii))
36
37- The printing of runtime errors has been improved, including those from linked
38 processes.
39 ([Louis Pilfold](https://github.com/lpil))
40
41- OTP application trees are now shut down gracefully when `main` exits.
42 ([Louis Pilfold](https://github.com/lpil))
43
44- The `gleam fix` command can now update a project's `gleam` version constraint
45 to make sure it respects the inferred minimum required version.
46 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
47
48- The build tool now refuses to publish a project where the `gleam` version
49 constraint would include a compiler version that doesn't support the features
50 used by the package.
51 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
52
53- If a project doesn't specify a `gleam` version constraint, the build tool will
54 automatically infer it and add it to the project's `gleam.toml` before
55 publishing it.
56 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
57
58### Compiler
59
60- Compiler progress is now printed to stderr, instead of stdout.
61 ([Victor Kobinski](https://github.com/vkobinski))
62
63- It is now possible to omit the `:utf8` option for literal strings used in a
64 `BitArray` segment.
65
66 ```gleam
67 <<"Hello", " ", "world">>
68 ```
69
70 Is the same as:
71
72 ```gleam
73 <<"Hello":utf8, " ":utf8, "world":utf8>>
74 ```
75
76 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
77
78- In inexhaustive pattern match errors the missing variants are now printed
79 using the correct syntax for the module the error is emitted in, rather than
80 the module it was defined in. For example, if you had this code:
81
82 ```gleam
83 import gleam/option
84
85 pub fn main() {
86 let an_option = option.Some("wibble!")
87 case an_option {
88 option.None -> "missing"
89 }
90 }
91 ```
92
93 The error message would show the qualified `option.Some(_)` as the missing
94 pattern:
95
96 ```txt
97 error: Inexhaustive patterns
98 ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:5:3
99 │
100 5 │ ╭ case an_option {
101 6 │ │ option.None -> "missing"
102 7 │ │ }
103 │ ╰───^
104
105 This case expression does not have a pattern for all possible values. If it
106 is run on one of the values without a pattern then it will crash.
107
108 The missing patterns are:
109
110 option.Some(_)
111 ```
112
113 ([Surya Rose](https://github.com/gearsdatapacks))
114
115- Anonymous functions that are immediately called with a record or a tuple as an
116 argument are now inferred correctly without the need to add type annotations.
117 For example you can now write:
118
119 ```gleam
120 fn(x) { x.0 }(#(1, 2))
121 // ^ you no longer need to annotate this!
122 ```
123
124 ([sobolevn](https://github.com/sobolevn))
125
126- Anonymous functions that are being piped a record or a tuple as an argument
127 are now inferred correctly without the need to add type annotations. For
128 example you can now write:
129
130 ```gleam
131 pub type User {
132 User(name: String)
133 }
134
135 pub fn main() {
136 User("Giacomo")
137 |> fn(user) { user.name }
138 // ^^^^ you no longer need to annotate this!
139 |> io.debug
140 }
141 ```
142
143 ([sobolevn](https://github.com/sobolevn))
144
145- The record pattern matching syntax `Record(a ..)` is now deprecated in favour
146 of the `Record(a, ..)` syntax.
147 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
148
149- Adds a better error message when module names are used as values. For example
150 the following code:
151
152 ```gleam
153 import gleam/list
154
155 pub fn main() {
156 list
157 }
158 ```
159
160 Results in the error:
161
162 ```txt
163 error: Module `list` used as a value
164 ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:4:3
165 │
166 4 │ list
167 │ ^^^^
168
169 Modules are not values, so you cannot assign them to variables, pass them to
170 functions, or anything else that you would do with a value.
171 ```
172
173 ([sobolevn](https://github.com/sobolevn))
174
175- An helpful error message has been added when the programmer attempts to write
176 a function within a custom type definition, likely trying to declare an OOP
177 class. For example:
178
179 ```gleam
180 pub type User {
181 User(name: String)
182
183 fn greet(user: User) -> String {
184 "hello " <> user.name
185 }
186 }
187 ```
188
189 Now results in the following error:
190
191 ```txt
192 error: Syntax error
193 ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:8:3
194 │
195 8 │ fn greet(user: User) -> String {
196 │ ^^ I was not expecting this
197
198 Found the keyword `fn`, expected one of:
199 - `}`
200 - a record constructor
201 Hint: Gleam is not an object oriented programming language so
202 functions are declared separately from types.
203 ```
204
205 ([sobolevn](https://github.com/sobolevn))
206
207- The compiler now gives a hint to import a module when accessing modules that
208 aren't imported. It only suggests a module if it exports a type/value with
209 the same name as what the user was trying to access:
210
211 ```gleam
212 pub fn main() {
213 io.println("Hello, world!")
214 }
215 ```
216
217 Produces the following error:
218
219 ```
220 error: Unknown module
221 ┌─ /src/file.gleam:2:3
222 │
223 2 │ io.println("Hello, world!")
224 │ ^^
225
226 No module has been found with the name `io`.
227 Hint: Did you mean to import `gleam/io`?
228 ```
229
230 This code, however, produces no hint:
231
232 ```gleam
233 pub fn main() {
234 io.non_existent()
235 }
236 ```
237
238 ([Surya Rose](https://github.com/gearsdatapacks))
239
240- The compiler now provides improved suggestions in the error for an
241 inexhaustive case expression. The following code:
242
243 ```gleam
244 let a = True
245 case a {}
246 ```
247
248 Now produces this error:
249
250 ```
251 error: Inexhaustive patterns
252 ┌─ /src/file.gleam:3:3
253 │
254 3 │ case a {}
255 │ ^^^^^^^^^
256
257 This case expression does not have a pattern for all possible values. If it
258 is run on one of the values without a pattern then it will crash.
259
260 The missing patterns are:
261
262 False
263 True
264 ```
265
266 Whereas before, it would suggest `_` as the only missing pattern.
267 ([Surya Rose](https://github.com/GearsDatapacks))
268
269- Improve error message for using `@external` with unknown target
270 ([Jiangda Wang](https://github.com/frank-iii))
271
272- Improved error title when using an unknown module value.
273 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
274
275- The compiler now shows an helpful error message if you try writing an `if`
276 expression instead of a case. For example, this code:
277
278 ```gleam
279 pub fn main() {
280 let a = if wibble {
281 1
282 }
283 }
284 ```
285
286 Results in the following error:
287
288 ```txt
289 error: Syntax error
290 ┌─ /src/parse/error.gleam:3:11
291 │
292 3 │ let a = if wibble {
293 │ ^^ Gleam doesn't have if expressions
294
295 If you want to write a conditional expression you can use a `case`:
296
297 case condition {
298 True -> todo
299 False -> todo
300 }
301
302 See: https://tour.gleam.run/flow-control/case-expressions/
303 ```
304
305 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
306
307- The compiler can now infer the minimum Gleam version needed for your code to
308 compile and emits a warning if the project's `gleam` version constraint
309 doesn't include it.
310 For example, let's say your `gleam.toml` has the constraint
311 `gleam = ">= 1.1.0"` and your code is using some feature introduced in a later
312 version:
313
314 ```gleam
315 // Concatenating constant strings was introduced in v1.4.0!
316 pub const greeting = "hello " <> "world!"
317 ```
318
319 You would now get the following warning:
320
321 ```txt
322 warning: Incompatible gleam version range
323 ┌─ /Users/giacomocavalieri/Desktop/datalog/src/datalog.gleam:1:22
324 │
325 1 │ pub const greeting = "hello " <> "world!"
326 │ ^^^^^^^^^^^^^^^^^^^^ This requires a Gleam version >= 1.4.0
327
328 Constant strings concatenation was introduced in version v1.4.0. But the
329 Gleam version range specified in your `gleam.toml` would allow this code to
330 run on an earlier version like v1.1.0, resulting in compilation errors!
331 Hint: Remove the version constraint from your `gleam.toml` or update it to be:
332
333 gleam = ">= 1.4.0"
334 ```
335
336 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
337
338- On the JavaScript target, non-byte aligned integers in bit array patterns are
339 now reported as a compile-time error.
340
341 ([Richard Viney](https://github.com/richard-viney))
342
343### Formatter
344
345- The formatter now adds a `todo` after a `use` expression if it is the last
346 expression in a block. For example, the following code:
347
348 ```gleam
349 pub fn main() {
350 use user <- result.try(fetch_user())
351 }
352 ```
353
354 Is rewritten as:
355
356 ```gleam
357 pub fn main() {
358 use user <- result.try(fetch_user())
359 todo
360 }
361 ```
362
363 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
364
365### Language Server
366
367- The language server can now show completions for local variables inside a function.
368 ([Ezekiel Grosfeld](https://github.com/ezegros))
369
370- The language server can now suggest a code action to assign an unused value to
371 `_`.
372 ([Jiangda Wang](https://github.com/frank-iii))
373
374- The language server can now suggest a code action to import modules for
375 existing code which references unimported modules:
376
377 ```gleam
378 pub fn main() {
379 io.println("Hello, world!")
380 }
381 ```
382
383 Becomes:
384
385 ```gleam
386 import gleam/io
387
388 pub fn main() {
389 io.println("Hello, world!")
390 }
391 ```
392
393 ([Surya Rose](https://github.com/gearsdatapacks))
394
395- The Language Server can now suggest a code action to fill in the missing
396 patterns of a case expression:
397
398 ```gleam
399 let a = True
400 case a {}
401 ```
402
403 Becomes:
404
405 ```gleam
406 let a = True
407 case a {
408 False -> todo
409 True -> todo
410 }
411 ```
412
413 ([Surya Rose](https://github.com/GearsDatapacks))
414
415### Bug Fixes
416
417- Fixed a bug where the warnings were printed above the errors without any new
418 line between them.
419 ([Victor Kobinski](https://github.com/vkobinski))
420
421- Fixed a bug which caused the language server and compiler to crash when two
422 constructors of the same name were created.
423 ([Surya Rose](https://github.com/GearsDatapacks))
424
425- Fixed a bug where jumping to the definition of an unqualified function would
426 produce the correct location, but remain in the same file.
427 ([Surya Rose](https://github.com/gearsdatapacks))
428
429- Fixed a bug where incorrect syntax error message were shown, when using `:` or
430 `=` in wrong positions in expressions.
431 ([Ankit Goel](https://github.com/crazymerlyn))
432
433- Fixed a bug where the compiler would crash when pattern matching on a type
434 which had constructors of duplicate names.
435 ([Surya Rose](https://github.com/gearsdatapacks))
436
437- Fixed a bug where referencing record constructors in JavaScript constants but
438 not calling them could produce invalid code.
439 ([Louis Pilfold](https://github.com/lpil))
440
441- Fixed a bug where source links in HTML documentation would be incorrect for
442 Codeberg, SourceHut, and Gitea.
443 ([sobolevn](https://github.com/sobolevn))
444
445- Fixed a bug with Erlang code generation for discard utf8 patterns in bit
446 arrays.
447 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
448
449- Fixed a bug which affected inference of function calls in pipe expressions.
450 ([sobolevn](https://github.com/sobolevn))
451
452- Improved an error message when using variable names starting with an
453 underscore in expression like: `let some = _func()` or `case { 1 -> _func() }`
454 ([sobolevn](https://github.com/sobolevn))
455
456- Fixed a bug where the provided `REBAR_BARE_COMPILER_OUTPUT_DIR` env var would
457 use relative path instead of absolute path causing compilation errors in some
458 packages.
459 ([Gustavo Inacio](https://github.com/gusinacio))
460
461- Fixed a bug where the compiler would print incorrect missing patterns for
462 inexhaustive case expressions matching on more than one subject.
463 ([Surya Rose](https://github.com/GearsDatapacks))
464
465- Fixed a bug where the compiler would not check the target support of a
466 function if it was imported and not used, and generate invalid code.
467 ([Surya Rose](https://github.com/GearsDatapacks))
468
469- Fixed a bug where an qualified unused constructor wouldn't be reported as
470 unused.
471 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
472
473- The Language Server now correctly shows completions for values in the Gleam
474 prelude.
475 ([Surya Rose](https://github.com/GearsDatapacks))
476
477- Fixed a bug where the language server wouldn't let you jump to the definition
478 of a function with an external implementation defined in the same module.
479 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
480
481## v1.4.1 - 2024-08-04
482
483### Bug Fixes
484
485- Fix a bug that caused record accessors for private types to not be completed
486 by the LSP, even when in the same module.
487 ([Ameen Radwan](https://github.com/Acepie))