Skip to content

Move *::Serializable's private constructors into macro included hook#16147

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/serializable-kwargs-initialize
Sep 10, 2025
Merged

Move *::Serializable's private constructors into macro included hook#16147
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/serializable-kwargs-initialize

Conversation

@HertzDevil
Copy link
Contributor

Fixes #16140.

As a bonus, it is now possible to refer to generic type variables inside converters (see #16142 (comment) for an example).

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:serialization labels Sep 8, 2025
@straight-shoota straight-shoota added this to the 1.18.0 milestone Sep 8, 2025
@straight-shoota straight-shoota merged commit 1fc065c into crystal-lang:master Sep 10, 2025
41 checks passed
@Sija
Copy link
Contributor

Sija commented Sep 11, 2025

This might have caused some regression?

See:

Seems like it's resolving JSON/YAML to Money::Registry::Converter::JSON/YAML for some reason...?

@HertzDevil
Copy link
Contributor Author

Yeah the converter expression is now resolved in the includer's scope rather than JSON::Serializable; it can be something like a Call, so adding special cases for Paths is insufficient, and we need a language feature like C++'s using inside defs to have the best of both worlds.

Personally I'd argue that using JSON::Serializable as the scope is a less natural expectation.

@HertzDevil HertzDevil deleted the bug/serializable-kwargs-initialize branch October 2, 2025 14:37
akadusei added a commit to GrottoPress/mel that referenced this pull request Oct 28, 2025
```

Which expanded to:

 > 18 |   **job_args
 > 19 | ) : String?
 > 20 |   job = new(**job_args)
                ^--
Error: no overload matches 'CollectJobsJob.new' with type

Overloads are:
 - CollectJobsJob.new(pull : ::JSON::PullParser)
 - CollectJobsJob.new(*, __pull_for_json_serializable pull : ::JSON::PullParser)
```

This is likely due to <crystal-lang/crystal#16147>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:serialization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

*::Serializable modules incompatible with pure kwargs initializers

4 participants