r/programminghumor • • Mar 02 '26 • Bravo 1

Cursor would neverrr

Post image
2.3k Upvotes

155 comments sorted by

View all comments

238

u/talbakaze Mar 02 '26 • Popcorn

return recalculate()

return recalculate()

the comment stated that it had to be recalculated twice

52

u/coderman64 Mar 02 '26

But it...it won't be...

21

u/TwinkiesSucker Mar 02 '26

The times code design is about what it actually does instead of what we think it does are long gone

4

u/Elia_31 Mar 03 '26

If it's doing something with global variables?

13

u/coderman64 Mar 03 '26

No, the first return exits the function entirely, so the second will never be executed.

It's a basic mistake that most linters will warn you about.

2

u/FloydATC Mar 04 '26

Pff, just redefine "return". Easy.

There may be side-effects.

7

u/Ashamed_Band_1779 Mar 02 '26

How is this not a compile error?

18

u/Stolberger Mar 02 '26

Usually it is just flagged as a warning "unreachable code", but might depend on the language and/or compiler and/or IDE

3

u/Gsusruls Mar 03 '26

And/or ci linting tool

3

u/TaiyouShinNoIbuki Mar 03 '26

Bravo future tech lead

2

u/-FTOH- Mar 06 '26

Sometimes it even may work...

function example() {
  try {
    return recalculate()
  } finally {
    return recalculate()
  }
}