Existence checks are missing in switch/pattern matching when using `that` #743
Labels
Comments
Merged
Indeed this can be seen even more easily like this: if a?
console.log that # => ReferenceError PR #895 might fix this. if a?
console.log that var that;
if (typeof a != 'undefined' && a !== null && (that = a, true)) {
console.log(that);
} if not a?
console.log that var that;
if ((that = undefined) || typeof a == 'undefined' || a === null) {
console.log(that);
} a = 10
if a?
console.log that var a;
a = 10;
if ((that = a) != null) {
console.log(that);
} a = 10
if not a?
console.log that var a;
a = 10;
if ((that = a) == null) {
console.log(that);
} The switch and while variants should work as well, and forms such as if a? and not b?
that work the same as before I believe. Any other cases to think about? :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code:
Produces this compiled output:
However, if you mention
that
in the return clause:It will compile to this:
Note missing checks for
foo
existence, so this code will die withReferenceError
whenfoo
is not defined, and it shouldn't happen.The text was updated successfully, but these errors were encountered: