Skip to content

Conversation

laa-odoo
Copy link
Collaborator

Task: 4735250

@robodoo
Copy link
Collaborator

robodoo commented Sep 29, 2025

Pull request status dashboard

@laa-odoo laa-odoo force-pushed the master-add-curly-brackets-laa branch 5 times, most recently from df549b5 to bb47554 Compare October 2, 2025 14:17
Allow entering literal arrays when composing formulas using curly brackets {}.

Task: 4735250
@laa-odoo laa-odoo force-pushed the master-add-curly-brackets-laa branch from bb47554 to 420ca7f Compare October 3, 2025 08:07
function leftOperandNeedsParenthesis(operationAST: ASTOperation | ASTUnaryOperation): boolean {
const mainOperator = operationAST.value;
const leftOperation = "left" in operationAST ? operationAST.left : operationAST.operand;
if (leftOperation.type !== "BIN_OPERATION") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed these lines ? It does the same thing (except the assignment of leftOperator), doesn't it ?

if (rightOperation.type !== "BIN_OPERATION") {
return false;
}
const rightPriority = OP_PRIORITY[rightOperation.value];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same questions as above

}
if (nextToken.type === "ARRAY_ROW_SEPARATOR") {
tokens.shift();
if (expectValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we want to have an empty cell inside the row of an array ? Isn't there any case where we sohuld want it ?

")": { type: "RIGHT_PAREN", value: ")" },
} as const;

const braces = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Maybe we can put these just before tokenizeBraces ?

export function extractFormulaIdFromToken(tokenAtCursor: EnrichedToken) {
const idAst = tokenAtCursor.functionContext?.args[0];
if (!idAst || !["STRING", "NUMBER"].includes(idAst.type)) {
if (!idAst || (idAst.type !== "STRING" && idAst.type !== "NUMBER")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Another useless diff. If you ally want to add them, maybe make another commit ?

}
const pivotFormulaId = extractFormulaIdFromToken(tokenAtCursor);
const pivotId = this.getters.getPivotId(pivotFormulaId);
if (pivotFormulaId === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes should go in another commit with all the others minor changes you made to improve the code

expect(() => parse("={1;}")).toThrow("Unexpected empty array element");
});

test("array literal with mismatched row length not throws", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array literal with mismatched row length DOES not throw

@anhe-odoo anhe-odoo changed the title Implement curly brackets [IMP] evaluation: implement curly brackets Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants