SOLVED: ERROR: `start` has no method matching start(::Nothing)

1,046 views
Skip to first unread message

Kaj Wiik

unread,
Jul 20, 2015, 3:09:00 PM7/20/15
to julia...@googlegroups.com
I started to get a strange error while debugging my code, here's a simplified example:

julia> function foo(a)
           println
("foo..")
       
end
foo
(generic function with 1 method)

julia
> a = foo(2)
foo
..

julia
> a,b = foo(2)
foo
..
ERROR
: `start` has no method matching start(::Nothing)


So, the problem was a missing return value, it is strange that missing one value did not give error but two values.... It took a quite long time to track this down. Perhaps a bit more informative error message would be possible...?

Cheers,
Kaj

Patrick O'Leary

unread,
Jul 20, 2015, 3:20:27 PM7/20/15
to julia...@googlegroups.com, kaj....@gmail.com
Julia is returning the value of `println("foo..")` from the function `foo()`; the value of the block expression is the value of the last expression in the block. It's turtles all the way down, so `println()` also returns a value in the same way, etc.

The error is because to destructure the return value into `a` and `b`, Julia iterates the return value. The return value of `foo`, which is the same as the return value from `println`, is something which is not iterable.

I agree that the error message isn't very helpful, but it's also hard to say how one would fix that.

Kaj Wiik

unread,
Jul 20, 2015, 3:30:56 PM7/20/15
to julia...@googlegroups.com

OK, thanks, obvious...

Search results did not help much either, that was main reason of my post, perhaps soon they will...

Thanks,
Kaj

Simon Danisch

unread,
Jul 20, 2015, 3:36:06 PM7/20/15
to julia...@googlegroups.com
This could actually be solved by having something like this in base:

start{T}(x::T) = error("$T is not iterable. Try implementing start(::$T), done(::$T, state), next(::$T, state)")

The basic problem here is, that Julia has weakly enforced interfaces, which often ends in no method errors instead of something meaningfull for people who don't know the implicit interfaces.

Patrick O'Leary

unread,
Jul 20, 2015, 4:07:30 PM7/20/15
to julia...@googlegroups.com, sdan...@gmail.com
That addresses one class of problem, but the two problems I see from Kaj's original post wouldn't be addressed: one, that the incorrect return value from foo() is silently accepted in the no-destructuring case, and two, that when destructuring, you still get an error message about iteration, even though it's not clear what is failing to be iterated.

Seth

unread,
Jul 20, 2015, 5:38:46 PM7/20/15
to julia...@googlegroups.com, sdan...@gmail.com
Is it possible to specify the type of a function/method's return value? That is, if it were possible to define foo() so that we knew it would return an Int64, say, then 1) we could guarantee type stability, and 2) we could also throw a warning or error if it returned something else.

Yichao Yu

unread,
Jul 20, 2015, 5:44:02 PM7/20/15
to Julia Users, sdan...@gmail.com
On Mon, Jul 20, 2015 at 5:38 PM, Seth <catc...@bromberger.com> wrote:
> Is it possible to specify the type of a function/method's return value? That
> is, if it were possible to define foo() so that we knew it would return an
> Int64, say, then 1) we could guarantee type stability, and 2) we could also
> throw a warning or error if it returned something else.

See various discussion here[1].

[1] https://github.com/JuliaLang/julia/issues/1090

Simon Danisch

unread,
Jul 20, 2015, 6:30:12 PM7/20/15
to julia...@googlegroups.com
@Patrick O'Leary  solved was probably exaggerated...But would be a lot better =)
The connection between iteration and asigning multiple variables to one return value is easier made than a no method error about a function you might have never heard about.


Am Montag, 20. Juli 2015 21:09:00 UTC+2 schrieb Kaj Wiik:

Ismael VC

unread,
Jul 21, 2015, 4:46:11 PM7/21/15
to julia-users
Not related, but how do you edit the thread name in order to mark it as SOLVED? I haven't found a way to do this, thanks!

Kaj Wiik

unread,
Jul 21, 2015, 6:32:00 PM7/21/15
to julia-users
Hehe, I think you can't.

I marked it as solved from the start because, well, the problem itself was solved already :-).

About error messages, I think Simons suggestion "$T is not iterable..." would have lead me to the correct conclusion bit faster...

Anyway, thanks for a good discussion and for your work on this lovely language!

Cheers,
Kaj
Reply all
Reply to author
Forward
0 new messages