You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,48 @@
12
12
of custom type variants.
13
13
([Adi Salimgereyev](https://github.com/abs0luty))
14
14
15
+
- Type inference now preserves generic type parameters when constructors or functions are used without explicit annotations, eliminating false errors in mutually recursive code:
16
+
```gleam
17
+
pub type Foo(a) {
18
+
Foo(value: Int)
19
+
}
20
+
21
+
pub fn main() {
22
+
Foo(1)
23
+
}
24
+
```
25
+
This now infers `fn main() -> Foo(a)`.
26
+
Likewise, mutually recursive functions compile without spurious errors:
27
+
```gleam
28
+
type Test(a) {
29
+
Test(a)
30
+
}
31
+
32
+
fn it(value: Test(a)) {
33
+
it2(value)
34
+
}
35
+
36
+
fn it2(value: Test(a)) -> Test(a) {
37
+
it(value)
38
+
}
39
+
```
40
+
Previously this could fail with an incorrect "Type mismatch" error:
41
+
```
42
+
Type mismatch
43
+
44
+
The type of this returned value doesn't match the return type
45
+
annotation of this function.
46
+
47
+
Expected type:
48
+
49
+
Test(a)
50
+
51
+
Found type:
52
+
53
+
Test(a)
54
+
```
55
+
([Adi Salimgereyev](https://github.com/abs0luty))
56
+
15
57
- The compiler now emits a warning when a module contains no public definitions
16
58
and prevents publishing packages with empty modules to Hex.
Copy file name to clipboardExpand all lines: compiler-core/src/language_server/tests/snapshots/gleam_core__language_server__tests__action__type_variables_in_let_bindings_are_considered_when_adding_annotations.snap
0 commit comments