300Re: return [expression] -> "unable to continue"
- Oct 30, 2008--- In email@example.com, "crlender" <crlender@...> wrote:
>I think by "fail" you meant that it succeeded in finding the weakness
> The following example causes the JSLint parser to fail:
in your code.
> return cache = calculate();This is explained in the documentation. When = is used in an
> Using extra parentheses works:
> return (cache = calculate());
> Since parens are not required here (ECMA-262, ed3, 12.9), and JSLint
> normally complains about extra parens, I wanted to ask if that's on
> purpose or a bug?
expression, there is a high likelihood that it is an error caused by
mistyping == or ===. From a careful reading of your code, I can't be
sure if your code is in error or not. That is not good. You want your
code to be more clearly correct. By wrapping the assignment in parens,
you are demonstrating that you are doing this deliberately.
I recommend avoiding assignment in expressions. I think
cache = calculate();
is cleaner and more bug resistant.
- << Previous post in topic Next post in topic >>