Skip to content

Conversation

@abs0luty
Copy link
Contributor

@abs0luty abs0luty commented Oct 20, 2025

@abs0luty abs0luty force-pushed the spreading-in-const-records branch 3 times, most recently from b2242d8 to 200b09a Compare October 23, 2025 11:23
@abs0luty abs0luty changed the title Implement record spreading in const values Allow spreading const records in type constructors for const values Oct 23, 2025
@abs0luty abs0luty changed the title Allow spreading const records in type constructors for const values Allow spreading records in type constructors for const values Oct 23, 2025
@abs0luty abs0luty force-pushed the spreading-in-const-records branch 4 times, most recently from 50c471a to df799f4 Compare October 27, 2025 19:31
@abs0luty abs0luty force-pushed the spreading-in-const-records branch from df799f4 to 5d39a71 Compare October 31, 2025 06:18
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This will be a relly nice addition. I've left a few questions in line.

Could you add a test that ensures that pub const dog = Animal(..alice) emits the "fieldless record update" warning please 🙏

@lpil lpil marked this pull request as draft November 10, 2025 13:41
@abs0luty abs0luty force-pushed the spreading-in-const-records branch 3 times, most recently from 84302ed to 5f48b6d Compare November 11, 2025 10:53
@abs0luty abs0luty requested a review from lpil November 11, 2025 10:54
@abs0luty abs0luty marked this pull request as ready for review November 11, 2025 13:13
@abs0luty abs0luty force-pushed the spreading-in-const-records branch 2 times, most recently from 7f5b0cd to 3ca3271 Compare November 24, 2025 15:49
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looking fab. I've left some notes inline, mostly around behaviour that doesn't match record updates for expressions.

@abs0luty abs0luty force-pushed the spreading-in-const-records branch 2 times, most recently from f8e45cb to faaa1e5 Compare December 1, 2025 13:44
@abs0luty abs0luty requested a review from lpil December 1, 2025 13:44
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a note inline!

@abs0luty abs0luty force-pushed the spreading-in-const-records branch from faaa1e5 to c6bb035 Compare December 1, 2025 19:09
@abs0luty abs0luty requested a review from lpil December 2, 2025 06:35
@abs0luty abs0luty force-pushed the spreading-in-const-records branch 4 times, most recently from 9326063 to e6a00d9 Compare December 2, 2025 17:11
@abs0luty
Copy link
Contributor Author

abs0luty commented Dec 3, 2025

I suppose I now need to accommodate for changes in c2fed7e!

@abs0luty abs0luty force-pushed the spreading-in-const-records branch 8 times, most recently from ed56e68 to 4f7ba1a Compare December 4, 2025 13:26
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the error messages for constants exactly the same as expressions please 🙏

Could we not return the same error value for constants as expressions? Then they would be rendered the same to the user.

@abs0luty
Copy link
Contributor Author

abs0luty commented Dec 5, 2025

@lpil Absolutely, I can work on this!

@abs0luty abs0luty force-pushed the spreading-in-const-records branch from 1dd8f75 to 57778f2 Compare December 5, 2025 16:28
@abs0luty abs0luty requested a review from lpil December 5, 2025 16:30
@abs0luty abs0luty force-pushed the spreading-in-const-records branch 3 times, most recently from a0f539f to 3ceec04 Compare December 5, 2025 19:51
@abs0luty
Copy link
Contributor Author

abs0luty commented Dec 5, 2025

@lpil Dependency validation fails and this is not directly related to the PR 🤔

```gleam
const a = Foo(1, 2)
const b = Foo(..a, 3)
```

Code like this now compiles, which makes constant construction a lot simpler!
Accommodate for recent changes to error handling in const inference in c2fed7e
Remove unused insta snapshots including ones left after renaming const record update tests.
Refactor the record update logic so const updates use the same error types as
regular record updates. This produces consistent messages for users and removes
cases where similar problems surfaced in different forms.

The change:
- restores InvalidRecordConstructor instead of InvalidRecordUpdate with reasons
- uses UnsafeRecordUpdate for variant mismatches to align with expression handling
- adds a constructor_location field so the compiler can point at the constructor when
  reporting InvalidRecordConstructor
- and introduces validation for incompatible field types in spreads
@abs0luty abs0luty force-pushed the spreading-in-const-records branch from 3ceec04 to 5a89ff1 Compare December 6, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow spreading const records in type constructors for consts

2 participants