Skip to content

methoderror for constructors considers typevars #33613

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

Closed
wants to merge 4 commits into from
Closed

methoderror for constructors considers typevars #33613

wants to merge 4 commits into from

Conversation

KlausC
Copy link
Contributor

@KlausC KlausC commented Oct 20, 2019

fix #33539

print(iob, use_constructor_syntax ? func : typeof(func).name.mt.name)
end
print(iob, "(")
print(iob, " ", func, "(")
Copy link
Member

Choose a reason for hiding this comment

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

Something like this to still highlight mismatches, like other arguments?

Suggested change
print(iob, " ", func, "(")
print(iob, " ")
if !isa(func, rewrap_unionall(s1, method.sig))
... Base.with_output_color(...); print(iob, func); end ...
else
print(iob, func)
end
print(iob, "("))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO that will be a very bad effort/result ratio, it the ... are extended. I would prefer to leave it as is.

for method in methods(func)
for (f, arg_types_param) in funcs
f2 = f isa UnionAll ? unwrap_unionall(unwrap_unionall(f).name.wrapper) : f
for method in methods(f2)
Copy link
Member

Choose a reason for hiding this comment

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

methods(unwrap_unionall(...)) is an invalid query—this must be called only on a properly wrapped object (e.g. the .wrapper)

Copy link
Contributor Author

@KlausC KlausC Oct 20, 2019

Choose a reason for hiding this comment

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

That was the original suggestion in #33539 (comment), and it obviously works for DataType.
Using the methods(... .name.wrapper) does not deliver all the methods we are after.
How would I have to "properly wrap" the object?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, right. methods can't do this query properly (which is its own shortcoming). You'd need to bypass it and call into the Base._methods_by_ftype function directly with f2 isa Type ? Type{<:f2} : typeof(f2).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see the point: If I @enter methods(f2) I end at

830      tt = signature_type(f, t)
831      return _methods_by_ftype(tt, lim, world)

1|julia> tt
Tuple{Type{Foo{T<:Integer,S,U}},Vararg{Any,N} where N}

That seems to be exactly the same, what you propose to call directly. The results are identical. Only difference is,
the methods throws an ArgumentError, if f2 isa Core.Builtin. So why shouldn't I simply call methods(f2)??

@KlausC
Copy link
Contributor Author

KlausC commented Oct 25, 2019

Bump.

@StefanKarpinski
Copy link
Member

@vtjnash has been traveling but it would be good to make forward progress on this.

@KlausC KlausC closed this Sep 7, 2020
@KlausC
Copy link
Contributor Author

KlausC commented Sep 7, 2020

there has been progress with the changed files, which resolve the issue better than this PR.

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

Successfully merging this pull request may close these issues.

Methoderror for constructors should consider typevars
3 participants