From ceface873d463e258d8bd74cf536d3f8955763a3 Mon Sep 17 00:00:00 2001 From: "Amy J. Ko" Date: Sat, 3 Aug 2024 08:35:41 -0700 Subject: [PATCH] Permit evaluation of functions with operator names without inputs. --- CHANGELOG.md | 1 + src/parser/parseExpression.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 876892246..f4ba2a379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http: - Repaired borrowed bindings from other sources. - Prevent project reevaluation during typing. +- Permit evaluation of functions with operator names without inputs. ## 0.10.7 2024-07-27 diff --git a/src/parser/parseExpression.ts b/src/parser/parseExpression.ts index c7305de6c..35cfb6bf1 100644 --- a/src/parser/parseExpression.ts +++ b/src/parser/parseExpression.ts @@ -239,8 +239,14 @@ function parseAtomicExpression(tokens: Tokens): Expression { : // Nones tokens.nextIs(Sym.None) ? parseNone(tokens) - : // Unary expressions before names and binary operators, since some unary can be multiple. - tokens.nextIsUnary() + : // Unary expressions are a unary operator and then any expression. + // The only exception is if it's immediately followed except for an eval open and close. This allows functions with operator names to be evaluated. + tokens.nextIsUnary() && + !tokens.nextAre( + Sym.Operator, + Sym.EvalOpen, + Sym.EvalClose, + ) ? new UnaryEvaluate( parseReference(tokens), parseAtomicExpression(tokens),