FluxML / Mjolnir.jl

A little less conversation, a little more abstraction
Other
87 stars 13 forks source link

Dynamic dispatch and Union type situations #4

Open shashi opened 4 years ago

shashi commented 4 years ago

Tracing may not be possible in situations where there is no unique next method to pick to trace. But this situation should occur way less with Mjolnir as opposed to using the standard Julia type inference as can be seen in this example

For example, if you have Dict{Any,Any} – we can see all the set and getindexes, so we can infer keys of the dictionary as if they were local variables

But should document when exactly it won't work, and provide reasonable suggestions to avoid those cases.

MikeInnes commented 4 years ago

Better yet, it would be nice if we could give precise diagnostics that say why code is untyped and how to fix it. This is still a bit abstract for me though; I'm hoping to see some failure cases from from users, which should help us explain mjolnir's failure cases in user terms.

There aren't that many sources of unions in standard Julia code. Iteration is one case that we should definitely support. Try/catch and recursive types are a source of Anys in normal Julia inference which we don't currently support; potentially we could make those things inferable though, e.g. if we have effect inference.