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

A very confusing message when calling the "delegate" macro incorrectly #6731

Open
dawkot opened this issue Sep 15, 2018 · 2 comments
Open

A very confusing message when calling the "delegate" macro incorrectly #6731

dawkot opened this issue Sep 15, 2018 · 2 comments

Comments

@dawkot
Copy link

dawkot commented Sep 15, 2018

When :to argument is skipped, this happens:

class C(T)
  
  delegate m, self.class
  
  def self.m
    T
  end
  
end

Error in line 3: instantiating 'm()'

in line 6: can't infer the type parameter T for the generic class C(T). Please provide it explicitly

@asterite
Copy link
Member

Well, delegate doesn't match the macro so the compiler tries to solve it as a method. To solve a method first the arguments are typed. Then m fails.

I can't see a way of improving this error message.

@willhbr
Copy link
Contributor

willhbr commented Jul 12, 2019

Could you just implement a second macro that doesn't take the to: argument, and raises a compile-time error with a clearer error message? (I'm happy to make a PR if this is a OK solution).

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

4 participants