Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect explicitly provided type vars for (Named)Tuple.new #10047

Merged
merged 2 commits into from Jan 18, 2021

Conversation

HertzDevil
Copy link
Contributor

Resolves #10041.

@@ -35,7 +35,22 @@ struct NamedTuple
# {} # syntax error
# ```
def self.new(**options : **T)
options
{% if @type.name(generic_args: false) == "NamedTuple" %}
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: it would be nice to know whether a type is an uninstantiated generic using a macro call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, this works slightly differently from the Slice.[] example because it's not possible to attach generic type vars to the macro call directly; they can only be attached via aliases (i.e. Bytes[...] is legal while Slice(UInt8)[...] isn't).

src/named_tuple.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota added this to the 0.36.0 milestone Jan 18, 2021
@bcardiff bcardiff merged commit 7e0fdb0 into crystal-lang:master Jan 18, 2021
@HertzDevil HertzDevil deleted the feature/tuple-new-type-vars branch January 27, 2021 07:46
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.

[RFC] Converting constructors for Tuple and NamedTuple
5 participants