Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That not a bug that static typing would catch as it is not a type bug.


What do you mean it is not a type bug? You've seen the fix with your own eyes. In the static language that fix would never have been needed, because the consumer would never have made the mistake that caused the miscalculation in the first place. Of course it is a type bug!

This is along the lines of

  def is_valid_email(email): return str(email).contains('@')
  
  class Person:
    ...
    def __str__(self): return $"{self.name} <{self.email}>"
  
  print(is_valid_email(Person(name='Peter @ Work', email=None)))


You can't get a NaN from a None value in Python. (Duck typing still has rules)

The error you have posted isn't a Python error.

Looking a bit deeper, the error occurs in C++ code. C++ is a statically typed language, last time I checked.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: