Skip to content

Add Struct.pre_initialize#15896

Merged
straight-shoota merged 5 commits intocrystal-lang:masterfrom
HertzDevil:feature/struct-pre-initialize
Jun 26, 2025
Merged

Add Struct.pre_initialize#15896
straight-shoota merged 5 commits intocrystal-lang:masterfrom
HertzDevil:feature/struct-pre-initialize

Conversation

@HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Jun 13, 2025

See #13481 (comment).

Note that there is no ReferenceStorage(T).pre_initialize, because ReferenceStorage < Value. Simply use T.pre_initialize in that case.

@HertzDevil
Copy link
Contributor Author

Regarding #13481 (comment), this construction never considers abstract structs; Bar.pre_initialize(Pointer(Foo).new(...)) will not write any type ID, and that Foo will become invalid. It is probably a good idea to disallow abstract structs altogether...?

@HertzDevil HertzDevil marked this pull request as draft June 13, 2025 08:55
@straight-shoota straight-shoota removed this from the 1.17.0 milestone Jun 14, 2025
@HertzDevil HertzDevil marked this pull request as ready for review June 23, 2025 19:31
@straight-shoota straight-shoota added this to the 1.17.0 milestone Jun 24, 2025
@straight-shoota straight-shoota merged commit 23d92eb into crystal-lang:master Jun 26, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants