Skip to content

Commit cecfd20

Browse files
committed
refactor: reverse sense of test for not as function call to clarify behavior
1 parent d92e00a commit cecfd20

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/expression/parse.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,15 +1230,16 @@ export const createParse = /* #__PURE__ */ factory(name, dependencies, ({
12301230
const saveState = Object.assign({}, state)
12311231

12321232
getTokenSkipNewline(state)
1233-
// If the current expression looks like `not(stuff...`, i.e. appears
1234-
// in the guise of function-call syntax, then we pass on it here and
1235-
// let it be picked up by the function-call parsing
1236-
// (the combo of parseSymbol/parseAccessors) later, so that it will
1237-
// have the exact behavior/precedence of a function call.
1238-
if (name !== 'not' || state.token !== '(') {
1233+
if (name === 'not' && state.token === '(') {
1234+
// This is the syntax of a unary function call with symbol `not`,
1235+
// so rather than handling here, we let it fall through to be handled
1236+
// by function-call parsing later.
1237+
Object.assign(state, saveState)
1238+
} else {
1239+
// Bona-finde "unary operator" application
12391240
const params = [parseUnary(state)]
12401241
return new OperatorNode(name, fn, params)
1241-
} else Object.assign(state, saveState)
1242+
}
12421243
}
12431244

12441245
return parsePow(state)

0 commit comments

Comments
 (0)