When are the types checked for values and parameters?

To further clarify my question, does the type check only happen at “runtime” (when you execute something) or can it happen separately from it? Is there an option to force check the types aside from just running the code?

I’ve found this project https://github.com/astrieanna/TypeCheck.jl that does something similar in Julia but it’s abandoned.

What’ I’m thinking is something akin to http://mypy-lang.org/, where you can check if the types are correct before you execute a code.

Although I know Julia will give an error when you run code where the types don’t match, this way of manual checking can be really useful for debugging purposes, and is something used daily by members of my team.

I mention this because I’m slowly convincing people at work that Julia is worth a try, and this came up as major question from one of the technical leaders.

This is definitely something we’d like to have in the future but it hasn’t become a top development priority just yet. If anyone’s interested in building a type checker (based on @astrieanna’s work or a fresh start), it would definitely be a great and useful project.


Thanks a lot for the answer! So the type is only checked when a code is executed, right?

I definitely would love to learn how to contribute for something like this (once I’m less green), maybe even convince said leader to help.

I don’t remember exactly when type inference get run for the first time, but it’s easy to run it yourself on a method and get the return type (it’s also stored in the method itself once it has been run IIRC). You can check this thread too:

1 Like

Interesting! This gives me some hints for implementing on my own code, but I’d definitely like to automate this type checking just like MyPy does. (and I bet this can be easier than Python since the type system is already built-in on Julia)