From 99ea45cb284d5628f51d7701545f79c4fe00bf6e Mon Sep 17 00:00:00 2001 From: galegosimpatico Date: Fri, 2 Feb 2018 16:09:13 +0000 Subject: [PATCH] Fix wrong parse of `(def()->string 'foo')()`. Duck tape issue #240. --- src/formula.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/formula.cpp b/src/formula.cpp index e5e9c4ffe..b0e66c459 100644 --- a/src/formula.cpp +++ b/src/formula.cpp @@ -4453,7 +4453,12 @@ static std::string debugSubexpressionTypes(ConstFormulaPtr & fml) if(op == nullptr) { if(i1->type == FFL_TOKEN_TYPE::LPARENS && (i2-1)->type == FFL_TOKEN_TYPE::RPARENS) { + // This `if` will prevent ` ( def ( ) -> int 32993 ) ( ) ` + // from being incorrectly interpreted as that + // ` def ( ) -> int 32993 ) ( ` must be parsed. + if (i2 - 2 >= i1 && (i2 - 2)->type != FFL_TOKEN_TYPE::LPARENS) { return parse_expression(formula_str, i1+1,i2-1,symbols, callable_def, can_optimize); + } } else if( (i2-1)->type == FFL_TOKEN_TYPE::RSQUARE) { //check if there is [ ] : either a list definition, or a operator const Token* tok = i2-2; int square_parens = 0;