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

Stack overflow on compiler #2604

Closed
fernandes opened this issue May 17, 2016 · 6 comments
Closed

Stack overflow on compiler #2604

fernandes opened this issue May 17, 2016 · 6 comments

Comments

@fernandes
Copy link
Contributor

Here is the carc that reproduces:

https://carc.in/#/r/ypb

I feel bad opening an issue with this title / description, but I'm not able to track it further

//cc @jhass

@asterite
Copy link
Member

I was able to reduce it further, but basically the problem is that the compiler isn't giving you an error for the @klass instance variable. In short, you can't have a variable with such type. Once I fix this you'll have to find another way to model this.

@asterite
Copy link
Member

Oh, didn't see @jhass came to almost the same conclusion...

@asterite
Copy link
Member

Reduced further to this:

require "spec"

class BlockHolder(T)
  def initialize(@klass : Class)
  end

  def klass
    @klass
  end
end

class Song
  @@block_holder : BlockHolder(Int32)?

  def self.build
    klass = @@block_holder.try &.klass
    klass.inspect
  end
end

describe "" do
  it "" do
    Song.build
  end
end

@jhass
Copy link
Member

jhass commented May 17, 2016

Reduced further

class BlockHolder(T)
  def initialize(klass_name : Class)
    @klass = klass_name
  end

  def call
    @klass
  end
end

class Song
  @@block_holder : BlockHolder(Song.class)?

  def self.build
    @@block_holder.try &.call
  end
end

class DotFormatter
  LETTERS = 1
  def report
    LETTERS + 1
  end
end

Song.build.class
DotFormatter.new.report

@fernandes
Copy link
Contributor Author

@asterite no problem, @jhass (thank you!) helped me with a better solution... just reporting to improve the language (amazing work btw 😄 👍 )

@fernandes
Copy link
Contributor Author

🙇 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants