Fix logical-assignment error handling - #212
Conversation
mozfreddyb
commented
Nov 1, 2022
- Fix unexpected AssignmentExpression in normalizeMethodCall #207: Chase right-hand side of AssignmentExpression in normalizeMethodCall
- Add more test case variations
- wip: issue Chasing method names in assignment should take operator into account #210 and normalizeMethodcall
rpl
left a comment
There was a problem hiding this comment.
@mozfreddyb follows some feedback about this PR.
(My apologies for the time I needed to get back to and to take a look into this PR).
| ">>>=", "&=", "|=", "^="]; | ||
|
|
||
| // operators where we don"t know the result of a logical expression, which may result in the code executing the left or the right part of the assignmentcan check the left bit: | ||
| const LOGICAL_OPERATOS = ["||=", "&&=", "??="]; |
| // Issue #210: oh, no! we have two methods names we need to check, but this function | ||
| // may only return one. it's not immediately clear how to reconcile that with existing callers of normalizeMethodCall. | ||
| methodName = ""; |
There was a problem hiding this comment.
// Issue #210: oh, no! we have two methods names we need to check, but this function
may only return one. it's not immediately clear how to reconcile that with existing callers of normalizeMethodCall.
how about changing this method to return an array of method names and on the caller side to expect an array to be always returned and iterate on that array to check all method names returned?
| } | ||
| else { | ||
| // this is the forcing function for us to complain about and implement support if new JS operators come up. | ||
| this.reportUnsupported(node, "Unexpected callable", `unexpected assignment with operator '${node.operator}' in normalizeMethodCall`); |
There was a problem hiding this comment.
thought: I think that we may be able to cover this branch with a test case using that parser: require.resolve("../parsers/fantasy-operator") approach we used in some other test cases in the past for similar reasons.