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

Semantic: add bindings for Union and ProcNotation #5807

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

makenowjust
Copy link
Contributor

Fixed #5805

The reason of #5805 is missing to check untyped in union types.
And ProcNotation has the same problem. It is fixed also.

@RX14 RX14 requested a review from asterite March 11, 2018 12:52
…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 makenowjust force-pushed the fix/crystal/ealry-return-for-untyped-union-and-proc-type branch from 195cf68 to 4cdf33e Compare March 12, 2018 05:46
@makenowjust
Copy link
Contributor Author

makenowjust commented Mar 12, 2018

I pushed a new commit.

See this weird result. I fixed this in the new commit.

def foo
  a = 1
  loop do
    b = [] of typeof(a)
    p typeof(b)
    a = "hello"
    break
  end
end

def bar
  a = 1
  loop do
    b = [] of typeof(a) | Int32 # <- use union type instead bare typeof
    p typeof(b)
    a = "hello"
    break
  end
end

foo # prints "Array(Int32 | String)"
bar # prints "Array(Int32)" !!?

This issue is little far from #5805, however the solution for this also fixes #5805 surely, so I pushed into this PR. I'll fix PR title.

@makenowjust makenowjust changed the title Semantic: fix behavior of union and proc notation with untyped expression Semantic: add bindings for Union and ProcNotation Mar 12, 2018
@felixbuenemann
Copy link
Contributor

@makenowjust Do you think this would also fix issue #5717?

I'm getting the following error since 0.24.1:

BUG: typeof(x) at … has no type

@makenowjust
Copy link
Contributor Author

I don't think this fixes #5717 because this fixes only union type and proc type, however it seems #5717 is not related to union type.

@straight-shoota
Copy link
Member

#5805 was fixed in #7475, but this PR still fixes other bugs and would be great to get this renewed.

@straight-shoota straight-shoota added the pr:needs-work A PR requires modifications by the author. label Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug pr:needs-work A PR requires modifications by the author. topic:compiler:semantic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: typeof(item) has no type
3 participants