Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Transformer issue #504

Open
ellik95 opened this issue Jul 6, 2023 · 0 comments
Open

Rule Transformer issue #504

ellik95 opened this issue Jul 6, 2023 · 0 comments

Comments

@ellik95
Copy link
Contributor

ellik95 commented Jul 6, 2023

Describe the bug
When we create a rule with anonymous function inside or array indexing it produces the below error:


 Transpiling... TypeError: Cannot read properties of undefined (reading 'isLeaf')
    at IntermediateASTTree.traverse (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/ast/core/intermediate-ast/IntermediateASTTree.js:74:25)
    at DomainRuleNodeTSTransformer.lookForParameterUsedAsIdentifierExpression (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/typescript-nest/ast/node-transformers/domainRule.js:63:19)
    at DomainRuleNodeTSTransformer.createThisMemberDotExpressionAndReplaceIdentifierExpression (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/typescript-nest/ast/node-transformers/domainRule.js:83:44)
    at DomainRuleNodeTSTransformer.prependThisToAllParametersUsedAsStatements (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/typescript-nest/ast/node-transformers/domainRule.js:31:22)
    at DomainRuleNodeTSTransformer.run (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/typescript-nest/ast/node-transformers/domainRule.js:15:14)
    at file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/typescript-nest/ast/index.js:40:37
    at IntermediateASTTree.traverse (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/ast/core/intermediate-ast/IntermediateASTTree.js:77:9)
    at IntermediateASTTree.traverse (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/ast/core/intermediate-ast/IntermediateASTTree.js:80:18)
    at IntermediateModelToASTTargetTransformer.transform (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/typescript-nest/ast/index.js:34:29)
    at TargetGenerator.generateCore (file:///Users/elli/.nvm/versions/node/v16.19.1/lib/node_modules/@bitloops/bitloops-language-cli/node_modules/@bitloops/bl-transpiler/lib/esm/src/target/index.js:19:72)

To Reproduce
create a rule like this:

 Rule UnreconciledTransactionsRule(financialTransactions: FinancialTransactionEntity[]) throws DomainErrors.TransactionIsNotUnreconciledError {
     transactionsAreNotUnreconciled: bool = false;
     const transactionsAreNotUnreconciledIds: int32[] = [];
     financialTransactions.forEach((financialTransaction) => {
         ...
     });
     isBrokenIf(transactionsAreNotUnreconciled == true, (transactionsAreNotUnreconciledIds));
 }

or like this:

Rule IsValidDateRule(date: string) throws DomainErrors.InvalidDateError {
    const day: int32 = date.split('-')[0];
    const year: int32 = date.split('-')[2];
    const month: int32 = date.split('-')[1];

    const invalidDay = day <= 0 OR day > 31;
    const invalidYear = year <= 2000 OR year > 2100;
    const invalidMonth = month <= 0 OR month > 12;

    isBrokenIf(invalidDay OR invalidYear OR invalidDay, (date));
}

Expected behavior
It is expected to transpile successfully.

Screenshots
image

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

No branches or pull requests

1 participant