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

BUG: typeof(item) has no type #5805

Closed
stepanvanzuriak opened this issue Mar 11, 2018 · 5 comments · May be fixed by #5807
Closed

BUG: typeof(item) has no type #5805

stepanvanzuriak opened this issue Mar 11, 2018 · 5 comments · May be fixed by #5807

Comments

@stepanvanzuriak
Copy link

stepanvanzuriak commented Mar 11, 2018

I try to write unwrap method but get error

  def unwrap(array)
    result = [] of typeof(array) | typeof(array.first)

    array.each do |item|
      if item.is_a?(Array)
        result = ([] of typeof(item) | typeof(item.first)) + result
        result.concat(item)
      else
        result << item
      end
    end

    result
  end

BUG: typeof(item) has no type

https://play.crystal-lang.org/#/r/3p6i

@makenowjust
Copy link
Contributor

Simplified version:

foo = 42
if foo.is_a?(String)
  [] of typeof(foo) | Int32
end

makenowjust added a commit to makenowjust/crystal that referenced this issue Mar 11, 2018
…sion

Fixed crystal-lang#5805

The reason of crystal-lang#5805 is missing to check untyped in union types.
And `ProcNotation` has the same problem. It is fixed also.
makenowjust added a commit to makenowjust/crystal that referenced this issue Mar 12, 2018
…sion

Fixed crystal-lang#5805

The reason of crystal-lang#5805 is missing to check untyped in union types.
And `ProcNotation` has the same problem. It is fixed also.
@felixbuenemann
Copy link
Contributor

felixbuenemann commented Mar 17, 2018

I think this might be the same problem as #5717.

@Blacksmoke16
Copy link
Member

This, #7441, and #7461 all seem to be hitting the same piece of code that raises that exception HERE. So all the issues seem to be related in that something is causing @type and @freeze_type to not exist. However, I don't know enough to take a guess as to why :/

@asterite
Copy link
Member

This and #7441 are similar and I already have a fix for them. #7461 is different, I need to reduce it more (that means it should be able to be reproducible if you pass --prelude=empty). I will try to do it later if I have time.

@asterite
Copy link
Member

Actually this and #7441 are also different :-P

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

Successfully merging a pull request may close this issue.

5 participants