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

Allow assignment to class var when fit this class var types of ancestors #4871

Conversation

makenowjust
Copy link
Contributor

Fix #4869

By this PR, you can compile this script:

class Foo
  @@x : Int32?

  def self.x
    @@x
  end
end

class Bar < Foo
  @@x = 42
end

pp Foo.x # => nil
pp Bar.x # => 42

@@ -135,7 +135,8 @@ struct Crystal::TypeDeclarationProcessor
# Process class variables
type_guess_visitor.class_vars.each do |owner, vars|
vars.each do |name, info|
declare_meta_type_var(owner.class_vars, owner, name, info)
# Not need to freeze its type because it is frozen by check_class_var_errors
Copy link
Contributor

Choose a reason for hiding this comment

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

Not => No

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.

@makenowjust makenowjust force-pushed the fix/crystal/allow-assign-class-var-if-fit-ancestors-type branch from 485d105 to ddc6871 Compare August 23, 2017 00:33
@sdogruyol
Copy link
Member

LGTM 👍 ?

@RX14 RX14 merged commit 842548e into crystal-lang:master Sep 1, 2017
@RX14 RX14 added this to the Next milestone Sep 1, 2017
@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Sep 1, 2017
@makenowjust makenowjust deleted the fix/crystal/allow-assign-class-var-if-fit-ancestors-type branch September 1, 2017 13:50
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:compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants