logoalt Hacker News

hyperhelloyesterday at 11:15 PM1 replyview on HN

> Division by zero is not a runtime error — it is a type error. The compiler checks every call site to prove the divisor is non-zero.

Elaborate a little here.


Replies

hgoeltoday at 1:08 AM

Presumably an analyzer that makes it an error to not have an immediately traceable zero check.

C# can do something similar with null references. It can require you to indicate which arguments and variables are capable of being null, and then compiler error/warning if you pass it to something that expects a non-null reference without a null check.

show 1 reply