Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
used on a variable followed by a case expression.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where the record field is forgotten by compiler when its
type is not valid.
([Adi Salimgereyev](https://github.com/abs0luty))

## v1.13.0-rc1 - 2025-09-29

### Compiler
Expand Down
2 changes: 1 addition & 1 deletion compiler-core/src/analyse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ impl<'a, A> ModuleAnalyzer<'a, A> {
Ok(t) => t,
Err(e) => {
self.problems.error(e);
continue;
environment.new_unbound_var()
}
};

Expand Down
21 changes: 21 additions & 0 deletions compiler-core/src/type_/tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3345,3 +3345,24 @@ fn type_used_as_a_constructor_with_more_arguments() {
}"
);
}

#[test]
fn remembering_record_field_when_type_checking_fails() {
assert_module_error!(
r#"pub type Wibble {
Wibble(x: Int, f: fn(Wobble) -> Int)
}

pub fn wibble() {
Wibble(1, fn(_) { 2 })
}

pub fn wobble(wibble: Wibble) {
wibble.f
}

pub fn woo(wibble: Wibble) {
Wibble(..wibble, x: 1)
}"#
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: compiler-core/src/type_/tests/errors.rs
expression: "pub type Wibble {\n Wibble(x: Int, f: fn(Wobble) -> Int)\n}\n\npub fn wibble() {\n Wibble(1, fn(_) { 2 })\n}\n\npub fn wobble(wibble: Wibble) {\n wibble.f\n}\n\npub fn woo(wibble: Wibble) {\n Wibble(..wibble, x: 1)\n}"
---
----- SOURCE CODE
pub type Wibble {
Wibble(x: Int, f: fn(Wobble) -> Int)
}

pub fn wibble() {
Wibble(1, fn(_) { 2 })
}

pub fn wobble(wibble: Wibble) {
wibble.f
}

pub fn woo(wibble: Wibble) {
Wibble(..wibble, x: 1)
}

----- ERROR
error: Unknown type
┌─ /src/one/two.gleam:2:24
2 │ Wibble(x: Int, f: fn(Wobble) -> Int)
│ ^^^^^^ Did you mean `Wibble`?

The type `Wobble` is not defined or imported in this module.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ is run on one of the values without a pattern then it will crash.

The missing patterns are:

Two
Two(_)
Loading