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

Fix to lookup NamedTuple from self #5466

Conversation

makenowjust
Copy link
Contributor

Fixed #5464

This bug prevents to work self restriction against NamedTuple.
So this code raises a compile error as same as #5464's, but now it works:

struct NamedTuple
  def self.foo : self
    {x: 42}
  end
end

pp NamedTuple.foo

Fixed crystal-lang#5464

This bug prevents to work `self` restriction against NamedTuple.
@makenowjust makenowjust changed the title Fix to look up NamedTuple from self Fix to lookup NamedTuple from self Dec 27, 2017
@asterite
Copy link
Member

asterite commented Jan 2, 2018

Even though this works, I'm not sure it's the correct fix. I'm not even sure it should compile. self here is NamedTuple, not NamedTuple(x : Int32). So for me it's fine that it doesn't compile.

As a side note, I started to dislike self in type restrictions lately, I'm inclined to remove it from the language. It only adds confusion.

@asterite
Copy link
Member

Closing because the original code with self shouldn't compile, or we simply need to remove the self restriction from the language.

@asterite asterite closed this Apr 29, 2018
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.

None yet

2 participants