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

Better error message for check_receiver_cap #3450

Merged
merged 2 commits into from
Jan 17, 2020

Conversation

adri326
Copy link
Member

@adri326 adri326 commented Jan 16, 2020

This addresses issue #2986 by:

  • giving a local equivalent to the this->x viewpoint adaptation (which is what is printed on the last line of the "Infos" section)
  • giving a hint when the this->x viewpoint adaptation turns into a box/val/iso in the current context while also trying to access a ref method

As an example, this is what the error from the code included in the original issue looks like on 0.33.1:

Error:
/_/main.pony:19:8: receiver type is not a subtype of target type
    fox()
       ^
    Info:
    /_/main.pony:19:5: receiver type: this->Fox ref
        fox()
        ^
    /_/main.pony:28:3: target type: Fox ref
      fun ref apply() =>
      ^
    /_/main.pony:10:12: Fox box is not a subtype of Fox ref: box is not a subcap of ref
      let fox: Fox ref

And this is what the error looks like with this patch:

Error:
/_/main.pony:19:8: receiver type is not a subtype of target type
    fox()
       ^
    Info:
    /_/main.pony:19:5: receiver type: this->Fox ref (which becomes 'Fox box' in this context)
        fox()
        ^
    /_/main.pony:28:3: target type: Fox ref
      fun ref apply() =>
      ^
    /_/main.pony:10:12: Fox box is not a subtype of Fox ref: box is not a subcap of ref
      let fox: Fox ref
               ^
    /_/main.pony:17:3: you are trying to change state in a box function; this would be possible in a ref function
      fun apply() =>
      ^

@SeanTAllen
Copy link
Member

@adri326 can you update the PR title to be something that would be meaningful in a CHANGELOG entry?

@SeanTAllen SeanTAllen added the changelog - changed Automatically add "Changed" CHANGELOG entry on merge label Jan 16, 2020
@adri326 adri326 changed the title Patch issue #2986 Better error message on check_receiver_cap Jan 16, 2020
@adri326 adri326 changed the title Better error message on check_receiver_cap Better error message for check_receiver_cap Jan 16, 2020
@adri326
Copy link
Member Author

adri326 commented Jan 16, 2020

@SeanTAllen there.

@SeanTAllen
Copy link
Member

Thanks @adri326.

Copy link
Contributor

@mfelsche mfelsche left a comment

Choose a reason for hiding this comment

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

Nice one!

@SeanTAllen SeanTAllen merged commit 6b7a7fd into ponylang:master Jan 17, 2020
@SeanTAllen
Copy link
Member

Thanks for the improvement @adri326.

github-actions bot pushed a commit that referenced this pull request Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - changed Automatically add "Changed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants