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

typeassert: Expected Type, got TypeVar with ANY keyword argument #21510

Closed
TotalVerb opened this issue Apr 23, 2017 · 3 comments
Closed

typeassert: Expected Type, got TypeVar with ANY keyword argument #21510

TotalVerb opened this issue Apr 23, 2017 · 3 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:lowering Syntax lowering (compiler front end, 2nd stage)

Comments

@TotalVerb
Copy link
Contributor

TotalVerb commented Apr 23, 2017

When a keyword argument is declared with ANY type, things don't work:

julia> foo(; a::ANY = Union{}) = a
foo (generic function with 1 method)

julia> foo(a=Union{})
ERROR: TypeError: typeassert: expected Type, got TypeVar
Stacktrace:
 [1] (::#kw##foo)(::Array{Any,1}, ::#foo) at ./<missing>:0

This may or may not be a problem (possibly it's intentional?); but if not, then the definition of Base.summarysize should be fixed.

function summarysize(obj::ANY;
                     exclude::ANY = Union{DataType, TypeName, Method},
                     chargeall::ANY = Union{TypeMapEntry, Core.MethodInstance})
@TotalVerb TotalVerb changed the title typeassert: Expected Type, got TypeVar typeassert: Expected Type, got TypeVar with ANY keyword argument Apr 23, 2017
@ararslan ararslan added the types and dispatch Types, subtyping and method dispatch label Apr 23, 2017
@JeffBezanson JeffBezanson self-assigned this Apr 24, 2017
@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior compiler:lowering Syntax lowering (compiler front end, 2nd stage) and removed types and dispatch Types, subtyping and method dispatch labels Apr 24, 2017
JeffBezanson added a commit that referenced this issue Apr 25, 2017
fix #21510, keyword arg with declared type `ANY`
@clouds56
Copy link
Contributor

It's not mentioned in document, what's the difference between ANY and Any when occurs in parameter list?
Only thing I know is Any is a DataType while ANY is a TypeVar (it seems ANY should not be used in parameter list)?

@KristofferC
Copy link
Member

ANY is removed. It is now @nospecialize.

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Oct 25, 2017

@clouds56, it was a hint to the compiler not to specialize the argument. The new @nospecialize annotation lets you convey the same thing, but still use a type besides Any, which is more flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:lowering Syntax lowering (compiler front end, 2nd stage)
Projects
None yet
Development

No branches or pull requests

6 participants