Gradualizer icon indicating copy to clipboard operation
Gradualizer copied to clipboard

Add safety for gen_server init?

Open FrankBro opened this issue 6 years ago • 2 comments

Would it be possible to make sure the init function of a gen_server:start and gen_server:start_link check the init function? Considering we pass the module as the first argument, it seems possible.

FrankBro avatar Apr 16 '20 01:04 FrankBro

It's a good idea but the current type system doesn't recognize a module as something other than an atom. It would be interesting but unless we think this is an extremely important case, I wouldn't want to add a special case for just that. If we don't add a special case, then we would need to extend the type system with a completely new concept that has no support in the type language.

Zalastax avatar Apr 17 '20 15:04 Zalastax

We could add hard-coded typing rules for gen_server and the other standard OTP behaviours...

Then, later, we can invent a way to let the users define their own typing rules for their user-defined behaviours...

zuiderkwast avatar Apr 24 '20 21:04 zuiderkwast