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: specify Void alias type as yiled output restriction #4591

Merged

Conversation

makenowjust
Copy link
Contributor

@makenowjust makenowjust commented Jun 19, 2017

You'll see Crystal's bizarre behavior.

These examples can work:

  1. def foo(&block : -> Void)
      yield
    end
    
    foo { 1 }
  2. def foo(&block : -> Void)
      block.call
    end
    
    foo { 1 }
  3. alias Foo = Void
    def foo(&block : -> Foo)
      block.call
    end
    
    foo { 1 }

However, this example fails with an error: "expected block to return Void, not Int32".

alias Foo = Void
def foo(&block : -> Foo)
  yield
end

foo { 1 }

This PR fixes it.

All examples are works:

1)

    def foo(&block : -> Void)
      yield
    end

    foo { 1 }

2)

    def foo(&block : -> Void)
      block.call
    end

    foo { 1 }

3)

    alias Foo = Void
    def foo(&block : -> Foo)
      block.call
    end

    foo { 1 }

However, this example fails with an error: "expected block to return Void, not Int32".

    alias Foo = Void
    def foo(&block : -> Foo)
      yield
    end

    foo { 1 }

This is bizarre behavior. Fixed for working it.
@RX14 RX14 merged commit 8ce76a6 into crystal-lang:master Aug 19, 2017
@RX14 RX14 added this to the Next milestone Aug 19, 2017
@Sija
Copy link
Contributor

Sija commented Aug 19, 2017

Hot damn! I'm giving my vote for @makenowjust as the new @crystal-lang ambassador/team member!

@makenowjust makenowjust deleted the fix/crystal/type-alias-restriction-yield branch August 19, 2017 23:32
@makenowjust
Copy link
Contributor Author

@Sija Thank you! I'd like to join @crystal-lang if possible.

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

Successfully merging this pull request may close these issues.

None yet

4 participants