diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 0d304337edb0b722278c4c15577833c4f7cda3a8..5872b9c841cf5dbce8dd6cc43104081e9cb18439 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -1236,7 +1236,15 @@ static bool IsConstantExpression(ir::AstNode *expr) if (expr->IsIdentifier()) { auto var = ResolveIdentifier(expr->AsIdentifier()); - return var != nullptr && var->Declaration()->IsConstDecl(); + if (var == nullptr || !var->Declaration()->IsConstDecl()) { + return false; + } + // ermolaevavarvara: Identifier is not constant if the variable is ArrowFunction (f.e. const foo = (n: number) + // => {} is not constant expr) + if (var->Declaration()->Node()->IsClassProperty()) { + return !var->Declaration()->Node()->AsClassProperty()->Value()->IsArrowFunctionExpression(); + } + return true; } if (expr->IsMemberExpression()) {