Project: aptanastudio
Issue APSTUD-4444: JS inference infers the type of logical expressions to be Boolean incorrectly
A logical expression in JavaScript using the operators || or && returns one of its operands, not a boolean evaluation of them as might be expected in other languages. Aptana 3.1.0.201202291203 incorrectly infers the type of a variable assigned to such an expression as Boolean without considering the type of its operands. An example is the very common JS idiom for giving an argument a default value or type in the case that it is omitted when the function is called: {code:JavaScript} function foo (optionalString) { optionalString = optionalString || ""; // if it's been left out, make sure it's a string. /* do other stuff... */ } {code} Inference could deduce the type of a logical expression to be the union of the types of its operands, but in my experience, the actual desired type is always the type of the right operand if it isn't Boolean.
Story points: 8