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
8Dedicated to the memory of Len Pilfold.
9
10## v1.8.0 - 2025-02-07
11
12## v1.8.0-rc1 - 2025-02-03
13
14### Compiler
15
16- Pipelines are now fault tolerant. A type error in the middle of a pipeline
17 won't stop the compiler from figuring out the types of the remaining pieces,
18 enabling the language server to show better suggestions for incomplete pipes.
19 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
20
21- Improved code generation for blocks in tail position on the Javascript target.
22 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
23
24- Function documentation comments and module documentation comments are now
25 included in the generated Erlang code and can be browsed from the Erlang
26 shell starting from OTP27.
27 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
28
29- Parsing of `case` expressions is now fault tolerant. If a `case` expressions
30 is missing its body, the compiler can still perform type inference. This also
31 allows the Language Server to provide completion hints for `case` subjects.
32 ([Surya Rose](https://github.com/GearsDatapacks))
33
34- The compiler can now suggest to wrap a value in an `Ok` or `Error` if that can
35 solve a type mismatch error:
36
37 ```gleam
38 pub fn greet_logged_user() {
39 use <- bool.guard(when: !logged_in, return: Error(Nil))
40 "Hello!"
41 }
42 ```
43
44 Results in the following error:
45
46 ```txt
47 error: Type mismatch
48 ┌─ /main.gleam:7:3
49 │
50 7 │ "Hello!"
51 │ ^^^^^^^^ Did you mean to wrap this in an `Ok`?
52
53 Expected type:
54
55 Result(a, Nil)
56
57 Found type:
58
59 String
60 ```
61
62 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
63
64- The compiler now shows an improved error message when using an unknown type as a
65 variable name
66
67 ```txt
68 error: Unknown variable
69 ┌─ /src/one/two.gleam:4:3
70 │
71 4 │ X
72 │ ^
73 The custom type variant constructor `X` is not in scope here.
74 ```
75
76 ([Roeeeee](https://github.com/5c077m4n))
77
78- Erlang `file` module attributes now use paths relative to the root.
79 ([Kasim](https://github.com/oneness))
80
81### Build tool
82
83- `gleam new` now has refined project name validation - rather than failing on
84 invalid project names, it suggests a valid alternative and prompts for
85 confirmation to use it.
86 ([Diemo Gebhardt](https://github.com/diemogebhardt))
87
88- `gleam docs build` generated documentation site now focuses the search input
89 when "Cmd/Ctrl + K", "s" or "/" is pressed.
90 ([Sambit Sahoo](https://github.com/soulsam480))
91
92- `gleam deps` now supports `tree` operation that lists the dependency tree.
93
94 ```markdown
95 Usage: gleam deps tree [OPTIONS]
96
97 Options:
98 -p, --package <PACKAGE> Package to be used as the root of the tree
99 -i, --invert <PACKAGE> Invert the tree direction and focus on the given package
100 -h, --help Print help
101 ```
102
103 For example, if the root project (`project_a`) depends on `package_b` and
104 `package_c`, and `package_c` also depends on `package_b`, the output will be:
105
106
107 ```markdown
108 $ gleam deps tree
109
110 project_a v1.0.0
111 ├── package_b v0.52.0
112 └── package_c v1.2.0
113 └── package_b v0.52.0
114
115 $ gleam deps tree --package package_c
116
117 package_c v1.2.0
118 └── package_b v0.52.0
119
120 $ gleam deps tree --invert package_b
121
122 package_b v0.52.0
123 ├── package_c v1.2.0
124 │ └── project_a v1.0.0
125 └── project_a v1.0.0
126
127 ```
128
129 ([Ramkarthik Krishnamurthy](https://github.com/ramkarthik))
130
131- The build tool now checks for modules that would collide with the new Erlang
132 `json` module in addition to the existing Erlang modules it already checked
133 for.
134 ([Louis Pilfold](https://github.com/lpil))
135
136### Language server
137
138- The language server can now generate the definition of functions that do not
139 exist in the current file. For example if I write the following piece of code:
140
141 ```gleam
142 import gleam/io
143
144 pub type Pokemon {
145 Pokemon(pokedex_number: Int, name: String)
146 }
147
148 pub fn main() {
149 io.println(to_string(pokemon))
150 // ^ If you put your cursor over this function that is
151 // not implemented yet
152 }
153 ```
154
155 Triggering the "generate function" code action, the language server will
156 generate the following function for you:
157
158 ```gleam
159 fn to_string(pokemon: Pokemon) -> String {
160 todo
161 }
162 ```
163
164 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
165
166- The language server can now fill in the labels of any function call, even when
167 only some of the arguments are provided. For example:
168
169 ```gleam
170 import gleam/string
171
172 pub fn main() {
173 string.replace("wibble")
174 }
175 ```
176
177 Will be completed to:
178
179 ```gleam
180 import gleam/string
181
182 pub fn main() {
183 string.replace("wibble", each: todo, with: todo)
184 }
185 ```
186
187 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
188
189- The language server now suggests a code action to pattern match on a
190 function's argument. For example:
191
192 ```gleam
193 pub type Pokemon {
194 Pokemon(pokedex_number: Int, name: String)
195 }
196
197 pub fn to_string(pokemon: Pokemon) {
198 // ^ If you put your cursor over the argument
199 todo
200 }
201 ```
202
203 Triggering the code action on the `pokemon` argument will generate the
204 following code for you:
205
206 ```gleam
207 pub type Pokemon {
208 Pokemon(pokedex_number: Int, name: String)
209 }
210
211 pub fn to_string(pokemon: Pokemon) {
212 let Pokemon(pokedex_number:, name:) = pokemon
213 todo
214 }
215 ```
216
217 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
218
219- The language server now suggests a code action to pattern match on a variable.
220 For example:
221
222 ```gleam
223 pub fn main() {
224 let result = list.first(a_list)
225 // ^ If you put your cursor over the variable
226 todo
227 }
228 ```
229
230 Triggering the code action on the `result` variable will generate the
231 following code for you:
232
233 ```gleam
234 pub fn main() {
235 let result = list.first(a_list)
236 case result {
237 Ok(value) -> todo
238 Error(value) -> todo
239 }
240 todo
241 }
242 ```
243
244 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
245
246- When generating functions or variables, the language server can now pick
247 better names using the type of the code it's generating.
248 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
249
250- The Language Server now provides the ability to rename local variables.
251 For example:
252
253 ```gleam
254 pub fn main() {
255 let wibble = 10
256 // ^ If you put your cursor here, and trigger a rename
257 wibble + 1
258 }
259 ```
260
261 Triggering a rename and entering `my_number` results in this code:
262
263
264 ```gleam
265 pub fn main() {
266 let my_number = 10
267 my_number + 1
268 }
269 ```
270
271 ([Surya Rose](https://github.com/GearsDatapacks))
272
273- `Unqualify` Action now get triggered when hovering over the module name
274 for record value constructor.
275 For example:
276
277 ```gleam
278 pub fn main() {
279 let my_option = option.Some(1)
280 // ^ would trigger "Unqualify option.Some"
281 }
282 ```
283 ([Jiangda Wang](https://github.com/Frank-III))
284
285### Formatter
286
287### Bug fixes
288
289- Fixed a bug where the "convert from use" code action would generate invalid
290 code for use expressions ending with a trailing comma.
291 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
292
293- Fixed a bug where floats outside of Erlang's floating point range were not
294 causing errors.
295 ([shayan](https://github.com/massivefermion))
296
297- Fixed a bug where build tool could fail to add new dependencies when
298 dependencies with optional dependencies are present in the manifest.
299 ([Louis Pilfold](https://github.com/lpil))
300
301- Fixed a bug where a block expression containing a singular record update would
302 produce invalid erlang.
303 ([yoshi](https://github.com/joshi-monster))
304
305- Fixed a typo in the error message when trying to import a test module into an
306 application module.
307 ([John Strunk](https://github.com/jrstrunk))
308
309- Fixed a bug where the "Extract variable" code action would erroneously extract
310 a pipeline step as a variable.
311 ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
312
313- Fixed a bug where variables bound in `let assert` assignments would be allowed
314 to be used in the custom panic message.
315 ([Surya Rose](https://github.com/GearsDatapacks))