Skip to content

Expand empty (Named)TupleLiteral to (Named)Tuple.new instead of {}#16108

Merged
straight-shoota merged 5 commits intocrystal-lang:masterfrom
spuun:empty-tupleliterals-expansion
Aug 25, 2025
Merged

Expand empty (Named)TupleLiteral to (Named)Tuple.new instead of {}#16108
straight-shoota merged 5 commits intocrystal-lang:masterfrom
spuun:empty-tupleliterals-expansion

Conversation

@spuun
Copy link
Contributor

@spuun spuun commented Aug 22, 2025

@HertzDevil
Copy link
Contributor

These type names must be global.

Co-authored-by: Johannes Müller <straightshoota@gmail.com>
@spuun
Copy link
Contributor Author

spuun commented Aug 22, 2025

These type names must be global.

Oh.. Hm. I though this was a low hanging fruit for me after digging around in code. 🙃

Trying to figure out what this means. Can you elaborate?

@straight-shoota
Copy link
Member

Global just means adding a :: prefix to the path. It should be ::Tuple.new and ::NamedTuple.new.

This avoids mistakes if a Tuple or NamedTuple type is defined in the current namespace.

@spuun
Copy link
Contributor Author

spuun commented Aug 22, 2025

Global just means adding a :: prefix to the path. It should be ::Tuple.new and ::NamedTuple.new.

This avoids mistakes if a Tuple or NamedTuple type is defined in the current namespace.

Ah, right. Of course!

@straight-shoota
Copy link
Member

The specs need the global path as well.

@spuun
Copy link
Contributor Author

spuun commented Aug 22, 2025

The specs need the global path as well.

On it! A little bit to trigger happy 😬

@straight-shoota straight-shoota added this to the 1.18.0 milestone Aug 23, 2025
@straight-shoota straight-shoota merged commit 4657f44 into crystal-lang:master Aug 25, 2025
39 checks passed
@straight-shoota straight-shoota added topic:lang:macros breaking-change May have breaking effect in some edge cases. Mostly negligible, but still noteworthy. and removed topic:stdlib:collection labels Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change May have breaking effect in some edge cases. Mostly negligible, but still noteworthy. kind:feature topic:lang:macros

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An empty NamedTupleLiteral should be interpolated to NamedTuple.new

4 participants