Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4435e5

Browse files
authored
Merge branch 'gleam-lang:main' into main
2 parents 72b7e39 + 7088612 commit f4435e5

File tree

415 files changed

+15584
-3463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

415 files changed

+15584
-3463
lines changed

.github/workflows/ci.yaml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ jobs:
8282
mix local.hex --force
8383
if: ${{ runner.os == 'macOS' }} # setup-beam does not support macOS
8484

85+
- name: Setup Node
86+
uses: actions/setup-node@v4
87+
with:
88+
node-version: "22"
89+
90+
- name: Setup Deno
91+
uses: denoland/setup-deno@v2
92+
with:
93+
deno-version: "2.2"
94+
95+
- name: Setup Bun
96+
uses: oven-sh/setup-bun@v2
97+
with:
98+
bun-version: "1.2"
99+
85100
- name: Handle Rust dependencies caching
86101
uses: Swatinem/rust-cache@v2
87102
with:
@@ -91,7 +106,7 @@ jobs:
91106
uses: clechasseur/rs-cargo@v3
92107
with:
93108
command: install
94-
args: "--path compiler-cli --target ${{ matrix.target }} --debug --locked --force"
109+
args: "--path gleam-bin --target ${{ matrix.target }} --debug --locked --force"
95110
tool: ${{ matrix.cargo-tool }}
96111
if: ${{ matrix.run-integration-tests }}
97112

@@ -116,7 +131,17 @@ jobs:
116131
uses: clechasseur/rs-cargo@v3
117132
with:
118133
command: test
119-
args: "--workspace --target ${{ matrix.target }}"
134+
# We only want to run the `test-output` when running integration tests.
135+
# There's a caveat though: when `cargo-tool` is `cross` it uses a container
136+
# and would result in these integration tests failing due to not finding
137+
# the escript binary. So, in case `cargo-tool != cargo` we'll skip the
138+
# `test-output` tests as well.
139+
args: >-
140+
--workspace
141+
--target ${{ matrix.target }}
142+
${{ ((matrix.run-integration-tests && matrix.cargo-tool == 'cargo')
143+
&& ' ')
144+
|| '--exclude test-output' }}
120145
tool: ${{ matrix.cargo-tool }}
121146

122147
- name: test/project_erlang (non-windows)
@@ -202,6 +227,13 @@ jobs:
202227
working-directory: ./test/project_path_deps/project_a
203228
if: ${{ matrix.run-integration-tests }}
204229

230+
- name: test/project_git_deps
231+
run: |
232+
gleam update
233+
gleam check
234+
working-directory: ./test/project_git_deps
235+
if: ${{ matrix.run-integration-tests }}
236+
205237
- name: Test project generation
206238
run: |
207239
gleam new lib_project
@@ -261,7 +293,7 @@ jobs:
261293

262294
- uses: actions/setup-node@v4
263295
with:
264-
node-version: "20"
296+
node-version: "22"
265297

266298
- name: Install wasm-pack
267299
run: |

CHANGELOG.md

Lines changed: 254 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
11
# Changelog
22

3-
## Unreleased
3+
## v1.9.0-rc1 - 2025-03-04
44

55
### Compiler
66

7+
- You can now use the `echo` keyword to debug print any value: `echo` can be
8+
followed by any expression and it will print it to stderr alongside the module
9+
it comes from and its line number. This:
10+
11+
```gleam
12+
pub fn main() {
13+
echo [1, 2, 3]
14+
}
15+
```
16+
17+
Will output to stderr:
18+
19+
```txt
20+
/src/module.gleam:2
21+
[1, 2, 3]
22+
```
23+
24+
`echo` can also be used in the middle of a pipeline. This:
25+
26+
```gleam
27+
pub fn main() {
28+
[1, 2, 3]
29+
|> echo
30+
|> list.map(fn(x) { x * 2 })
31+
|> echo
32+
}
33+
```
34+
35+
Will output to stderr:
36+
37+
```txt
38+
/src/module.gleam:3
39+
[1, 2, 3]
40+
/src/module.gleam:5
41+
[2, 4, 6]
42+
```
43+
44+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
45+
746
- Generated Erlang `.app` files now include external modules written in Elixir
847
and Erlang.
948
([LostKobrakai](https://github.com/lostkobrakai))
@@ -13,12 +52,48 @@
1352
making Gleam packages discoverable through global search of HexDocs.
1453
([Diemo Gebhardt](https://github.com/diemogebhardt))
1554

55+
- Improved the styling of constructor argument descriptions in the generated
56+
documentation.
57+
([Nicd](https://git.ahlcode.fi/nicd))
58+
1659
- Allow users to set the `GLEAM_CACERTS_PATH` environment variable to specify a
1760
path to a directory containing CA certificates to install Hex packages.
1861
([winstxnhdw](https://github.com/winstxnhdw))
1962

63+
- On the JavaScript target, bit array expressions and patterns no longer need to
64+
be byte aligned, and the `bits` segment type is now supported in patterns.
65+
([Richard Viney](https://github.com/richard-viney))
66+
67+
- The code generated for list pattern matching on the JavaScript target is now
68+
more efficient. Gleam code that relies heavily on list pattern matching can
69+
now be up to twice as fast.
70+
([yoshi~](https://github.com/yoshi-monster))
71+
72+
- On the JavaScript target, bit array patterns can now match segments of dynamic
73+
size.
74+
([Surya Rose](https://github.com/GearsDatapacks))
75+
76+
### Build tool
77+
78+
- The build tool now supports Git dependencies. For example:
79+
80+
```
81+
[dependencies]
82+
gleam_stdlib = { git = "https://github.com/gleam-lang/stdlib.git", ref = "957b83b" }
83+
```
84+
85+
([Surya Rose](https://github.com/GearsDatapacks))
86+
87+
- The build tool now refuses to publish any incomplete package that has any
88+
`echo` debug printing left.
89+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
90+
2091
### Language server
2192

93+
- The language server now has the ability to jump to the type definition of any
94+
hovered value.
95+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
96+
2297
- The language server now offers a code action to convert the first step of a
2398
pipeline to a regular function call. For example, this code:
2499

@@ -42,7 +117,51 @@
42117

43118
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
44119

45-
- The Language Server now suggests a code action to generate a function to
120+
- The language server now offers a code action to convert a function call into
121+
a pipeline. For example, this code:
122+
123+
```gleam
124+
import gleam/list
125+
126+
pub fn main() {
127+
list.map([1, 2, 3], fn(n) { n * 2 })
128+
}
129+
```
130+
131+
Will be rewritten as:
132+
133+
```gleam
134+
import gleam/list
135+
136+
pub fn main() {
137+
[1, 2, 3] |> list.map(fn(n) { n * 2 })
138+
}
139+
```
140+
141+
You can also pick which argument is going to be piped. In this case:
142+
143+
```gleam
144+
import gleam/list
145+
146+
pub fn main() {
147+
list.map([1, 2, 3], fn(n) { n * 2 })
148+
// ^ If you put your cursor over here
149+
}
150+
```
151+
152+
The code will be rewritten as:
153+
154+
```gleam
155+
import gleam/list
156+
157+
pub fn main() {
158+
fn(n) { n * 2 } |> list.map([1, 2, 3], _)
159+
}
160+
```
161+
162+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
163+
164+
- The language server now suggests a code action to generate a function to
46165
encode a custom type as JSON using the `gleam_json` package. For example:
47166

48167
```gleam
@@ -70,10 +189,143 @@
70189

71190
([Surya Rose](https://github.com/GearsDatapacks))
72191

192+
- The language server now suggests a code action to inline a variable
193+
which is only used once. For example, this code:
194+
195+
```gleam
196+
import gleam/io
197+
198+
pub fn main() {
199+
let greeting = "Hello!"
200+
io.println(greeting)
201+
}
202+
```
203+
204+
Will be rewritten as:
205+
206+
```gleam
207+
import gleam/io
208+
209+
pub fn main() {
210+
io.println("Hello!")
211+
}
212+
```
213+
214+
([Surya Rose](https://github.com/GearsDatapacks))
215+
216+
- The code action to generate a dynamic decoder for a custom type can now
217+
generate decoders for types with multiple variants. For example this code:
218+
219+
```gleam
220+
pub type Person {
221+
Adult(age: Int, job: String)
222+
Child(age: Int, height: Float)
223+
}
224+
```
225+
226+
Becomes:
227+
228+
```gleam
229+
import gleam/dynamic/decode
230+
231+
pub type Person {
232+
Adult(age: Int, job: String)
233+
Child(age: Int, height: Float)
234+
}
235+
236+
fn person_decoder() -> decode.Decoder(Person) {
237+
use variant <- decode.field("type", decode.string)
238+
case variant {
239+
"adult" -> {
240+
use age <- decode.field("age", decode.int)
241+
use job <- decode.field("job", decode.string)
242+
decode.success(Adult(age:, job:))
243+
}
244+
"child" -> {
245+
use age <- decode.field("age", decode.int)
246+
use height <- decode.field("height", decode.float)
247+
decode.success(Child(age:, height:))
248+
}
249+
_ -> decode.failure(todo as "Zero value for Person", "Person")
250+
}
251+
}
252+
```
253+
254+
([Surya Rose](https://github.com/GearsDatapacks))
255+
256+
- The language server now suggests a code action to easily interpolate a value
257+
into a string. If the cursor is inside a literal string the language server
258+
will offer to split it:
259+
260+
```gleam
261+
"wibble | wobble"
262+
// ^ Triggering the action with the cursor
263+
// here will produce this:
264+
"wibble " <> todo <> " wobble"
265+
```
266+
267+
And if the cursor is selecting a valid gleam name, the language server will
268+
offer to interpolate it as a variable:
269+
270+
```gleam
271+
"wibble wobble woo"
272+
// ^^^^^^ Triggering the code action if you're
273+
// selecting an entire name, will produce this:
274+
"wibble " <> wobble <> " woo"
275+
```
276+
277+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
278+
279+
- The language server now shows module documentation when hovering over a module
280+
name.
281+
([Surya Rose](https://github.com/GearsDatapacks))
282+
73283
### Formatter
74284

285+
- Redundant function captures that take no additional arguments are now
286+
rewritten to not use the function capture syntax.
287+
288+
```gleam
289+
some_module.some_function(_)
290+
```
291+
292+
This code is reformatted like so:
293+
294+
```gleam
295+
some_module.some_function
296+
```
297+
298+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
299+
75300
### Bug fixes
76301

302+
- Fixed a bug where division and remainder operators would not work correctly
303+
in guards on the JavaScript target.
304+
([Surya Rose](https://github.com/GearsDatapacks))
305+
306+
- Fixed a bug where the "Generate function" code action would ignore the
307+
provided labels.
308+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
309+
310+
- Fixed a bug where the "Pattern match on argument" and
311+
"Pattern match on variable" code actions would not allow to pattern match on a
312+
private type used in the same module it's defined in.
313+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
314+
315+
- Fixed a bug where `gleam export package-interface` would not properly generate
316+
the package interface file if some modules were cached.
317+
([Pedro Francisco](https://github.com/mine-tech-oficial)) and
318+
([Surya Rose](https://github.com/GearsDatapacks))
319+
320+
- Fixed a bug where pattern matching using a UTF-8 string constant would not
321+
work correctly on the JavaScript target when the string contained escape
322+
characters.
323+
([Richard Viney](https://github.com/richard-viney))
324+
325+
- Fixed a bug where `gleam publish` wouldn't include gitignored or nested native
326+
files.
327+
([PgBiel](https://github.com/PgBiel))
328+
77329
## v1.8.1 - 2025-02-11
78330

79331
### Bug fixes

0 commit comments

Comments
 (0)