Erlang / Erlang Advanced Interview questions
Why doesn't Dialyzer catch every type error the way a traditional type checker would?
Success typing is intentionally conservative: it only reports a call site when it can prove the function can never succeed with those argument types, based on inferring what the function's body could actually produce or accept. If a function's implementation is loose enough that a call is merely suspicious rather than provably impossible, Dialyzer stays silent about it.
maybe_int(X) when is_integer(X) -> X; maybe_int(X) -> X. %% falls through for ANY other type, so nothing is provably wrong bad() -> maybe_int("oops"). %% Dialyzer says nothing here
Because the second clause accepts any value unconditionally, Dialyzer can't prove the call fails, even
though it's clearly not what the author intended. This is the direct tradeoff for success typing's low
false-positive rate: it trades completeness (catching every questionable call) for
soundness of what it does report (never crying wolf on code that actually works). Writing precise
-spec annotations and using strict guards narrows this gap, but Dialyzer will never behave like a
type checker that rejects unproven code by default.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
