`ERROR: LoadError: TypeError: Type{...} expression: expected Type{T}, got Module`

What does the following error mean? It’s too general to understand.

ERROR: LoadError: TypeError: Type{...} expression: expected Type{T}, got Module
 in include_from_node1(::String) at ./loading.jl:488
 in eval(::Module, ::Any) at ./boot.jl:234
 in require(::Symbol) at ./loading.jl:415
 in reload(::String) at ./loading.jl:336
while loading /home/calvin/Documents/git/FastSum.jl/src/FastSum.jl, in expression starting on line 480

Also, I have nothing but a blank line on line 480. I find that it’s quite common that I don’t see anything wrong on the line indicated by the error message. Is this something happens to others? How can I locate the error more accurately if I don’t see anything on the indicated line? Thanks!

On another note - I find that the error thrown at the terminal in a second run differs from the error thrown when the code is run the very first time. How shall I understand this?

Bump up. Thanks.

What might be potential causes for this error?

In general, “bumping” a topic you created 9h ago is not necessary. People will see it when they look at the forum.

It could be that you gave the same name to a module and a type. Hard to say more without a MWE, if the problem is not obvious, try to uncomment pieces of your code and create an MWE you can post here.

Sorry, I was a bit desperate to get rid of this error. I’ll wait a little more in the future.

Thanks for the hint. I’ll try to work out a MWE to show the problem.

You can reproduce the expected Type{T} part of the error with

module Foo end

Also, note that the stacktrace includes a call to require, so it seems likey that this happens in a file include()ed in FastSum.jl.
Might also be worth looking at all instances of {.*} in your code.

Thanks for the hint. I wonder if it is possible that this error has nothing to do with include(). The doc of include() says that it sets the current include path but does not use it to search for files.[quote=“pfitzseb, post:5, topic:1230”]
Might also be worth looking at all instances of {.*} in your code.
Why does dot multiplication matter in this case? Any part of the error implies that?

Thanks a lot!!

@pfitzseb possibly meant a regex, ie { and } with something in between.

I see, but only partly. Which line of the error message tells this?

Well, under the assumption that the error can only be caused by an expression of the form ModuleName{Type}, a search for that (with the above regex, as @Tamas_Papp noted , or something similar) should turn up the culprit.

Also, you linked the docs for require, which you probably wont have called directly; include() on the other hand does explcitly search for files and evalutes them.

Going by the docs link above: Are you on 0.4? If so, is there anything that prevents you from using 0.5?

Apart from that: For us to give you any more specific help, we’d really have to see your code.

1 Like