19
Found a bug in my code that was hiding for 3 weeks
I was working on this little calculator app for my portfolio and kept getting wrong totals on one specific input. Tried everything, rewrote functions, checked my math like a dozen times. Finally yesterday I printed out the whole script on paper and went through it line by line. Turns out I had a typo in a variable name from like 3 weeks ago. I used 'userInpit' instead of 'userInput' and the compiler never even told me because the misspelled one was just undefined. So my code was just skipping that line silently the whole time. Felt like a dummy but also it was kinda cool to figure out. Has anyone else had a bug that was literally just a single wrong letter?
3 comments
Log in to join the discussion
Log In3 Comments
the_emery20d ago
Oh man, that's the worst (but also kinda impressive it worked for 3 weeks somehow). Guess your code was on a silent strike, huh? At least you found it before the internet did.
4
faith_king20d ago
Pushed all my error handling into a separate module that logs everything to a text file I check weekly. Lets me spot weird stuff like this without digging through piles of output. Saved my hide more than once when something ran silent but wrong.
3
sarah81820d ago
Funny enough, I used to just scroll past people talking about paper printouts for debugging. Figured it was some old school habit that would go away. But after spending a whole Saturday chasing a one character typo last month, I get it now.
2