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

Well, in Python, if you duplicate a return statement, then your code will recognize only the first statement. This, for example, will return 1:

  def func():
    return 1
    return 2
If the code from the goto fail example was written in Python so as to return an object when a condition was met, and it ended up with 2 return statements, then Python would have just returned the first one in the proper scope and moved on. Of course, this still depends on implementation in the code itself.


If we're talking about returns, then C/C++ would behave the same way. The second return is unreachable.

A duplicated line that isn't idempotent and that doesn't jump out of the current scope would be problematic.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: