The Daily WTF
Let’s say you were writing a type checker in TypeScript. At some point, you would find that you need to iterate across various lists of things, like for example, the list of arguments to a function.
Now, JavaScript (and thus TypeScript) gives you plenty of options for building the right loop for your specific problem. Or, if you look at the code our anonymous submitter sent, you could just choose the wrongest one.
var i = 0; var func1: string[] = func_e.get(expr.name); if (func1.length != 0) { do { var a = typeCheckExpr(expr.arguments[i], env); if (a != func1[i]) throw new Error(“Type mismatch in parameters”); i += 1; } while (i != expr.arguments.length); }
Now, it’s tricky to reconstruct what the intent of the code is with these wonderfully vague variable names, but I’m fairly certain that func1 contains information about the definition of the function, while expr is
To read the full article click on the 'post' link at the top.