diff --git a/ets2panda/compiler/core/ETSfunction.cpp b/ets2panda/compiler/core/ETSfunction.cpp index 4edd9d31b25ace531738391744a03630fe79e6ea..000f70b10565407ac013ffc7f4739d138e7090fc 100644 --- a/ets2panda/compiler/core/ETSfunction.cpp +++ b/ets2panda/compiler/core/ETSfunction.cpp @@ -123,6 +123,9 @@ void ETSFunction::CompileAsStaticBlock(ETSGen *etsg) // Check if it is the Global class static constructor and the special '_$init$_" method exists bool const compileInitializer = classDef->IsGlobal() ? checkInitializer(classDef->Body()) : true; + if (!compileInitializer) { + return; + } for (const auto *prop : classDef->Body()) { if (!prop->IsClassProperty() || !prop->IsStatic()) { @@ -131,10 +134,12 @@ void ETSFunction::CompileAsStaticBlock(ETSGen *etsg) // Don't compile variable initializers if they present in '_$init$_" method auto *const item = prop->AsClassProperty(); - if (item->Value() != nullptr && - (compileInitializer || item->IsConst() || item->Value()->IsArrowFunctionExpression())) { - item->Compile(etsg); + + if (item->Value() == nullptr) { + continue; } + + item->Compile(etsg); } } diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index de86a2313ab186649edd530ebc81029884aa2ead..cffbbc6adf23490e1bc439917ffc60543d902778 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -847,7 +847,8 @@ ir::AstNode *ConstantExpressionLowering::UnfoldConstIdentifier(ir::AstNode *node { ir::AstNode *resNode = nullptr; if (node->IsClassProperty()) { - auto prop = node->AsClassElement(); + auto prop = node->AsClassProperty(); + ES2PANDA_ASSERT(prop->Value() != nullptr); resNode = prop->Value()->Clone(context_->allocator, originNode->Parent()); resNode->SetRange(originNode->Range()); } diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp index dc8869fffa872ddab6fbd2b0acda0100c0a107b5..9bbde8cc5603fee660b657d2d63f54f1470d1177 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp @@ -14,6 +14,7 @@ */ #include "compiler/lowering/ets/topLevelStmts/globalDeclTransformer.h" +#include "compiler/lowering/util.h" namespace ark::es2panda::compiler { @@ -153,7 +154,7 @@ ir::Identifier *GlobalDeclTransformer::RefIdent(const util::StringView &name) ir::ExpressionStatement *GlobalDeclTransformer::InitTopLevelProperty(ir::ClassProperty *classProperty) { const auto initializer = classProperty->Value(); - if (classProperty->IsConst() || initializer == nullptr) { + if (initializer == nullptr) { classProperty->SetStart(classProperty->Id()->Start()); return nullptr; } @@ -172,11 +173,13 @@ ir::ExpressionStatement *GlobalDeclTransformer::InitTopLevelProperty(ir::ClassPr classProperty->SetRange({ident->Start(), initializer->End()}); - if (classProperty->TypeAnnotation() != nullptr) { + if (classProperty->TypeAnnotation() != nullptr && !classProperty->IsConst()) { classProperty->SetValue(nullptr); } else { // Code will be ignored, but checker is going to deduce the type. classProperty->SetValue(initializer->Clone(allocator_, classProperty)->AsExpression()); + RefineSourceRanges(classProperty->Value()); + assignmentExpression->SetIgnoreConstAssign(); } return expressionStatement; } diff --git a/ets2panda/ir/statements/switchCaseStatement.cpp b/ets2panda/ir/statements/switchCaseStatement.cpp index 1585c3b5bcddc7fd55c2bd83c452e938a3317fe8..be0ff2741f834c68645afb412547cebc3c8b79fb 100644 --- a/ets2panda/ir/statements/switchCaseStatement.cpp +++ b/ets2panda/ir/statements/switchCaseStatement.cpp @@ -146,7 +146,7 @@ void SwitchCaseStatement::CheckAndTestCase(checker::ETSChecker *checker, checker SwitchCaseStatement *SwitchCaseStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) { - auto *const test = test_->Clone(allocator, nullptr)->AsExpression(); + auto *const test = test_ == nullptr ? nullptr : test_->Clone(allocator, nullptr)->AsExpression(); ArenaVector consequent(allocator->Adapter()); for (auto *statement : consequent_) { diff --git a/ets2panda/lsp/src/api.cpp b/ets2panda/lsp/src/api.cpp index 9c9b2179527036257278edf70cd38a61bd0436cf..7d92576743544f3761c0a188b18aeeb8abd991aa 100644 --- a/ets2panda/lsp/src/api.cpp +++ b/ets2panda/lsp/src/api.cpp @@ -174,6 +174,7 @@ DiagnosticReferences GetSemanticDiagnostics(es2panda_Context *context) { DiagnosticReferences result {}; auto ctx = reinterpret_cast(context); + ctx->diagnosticEngine->CleanDuplicateLog(util::DiagnosticType::SEMANTIC); const auto &diagnostics = ctx->diagnosticEngine->GetDiagnosticStorage(util::DiagnosticType::SEMANTIC); for (const auto &diagnostic : diagnostics) { result.diagnostic.push_back(CreateDiagnosticForError(context, *diagnostic)); @@ -185,6 +186,7 @@ DiagnosticReferences GetSyntacticDiagnostics(es2panda_Context *context) { DiagnosticReferences result {}; auto ctx = reinterpret_cast(context); + ctx->diagnosticEngine->CleanDuplicateLog(util::DiagnosticType::SYNTAX); const auto &diagnostics = ctx->diagnosticEngine->GetDiagnosticStorage(util::DiagnosticType::SYNTAX); for (const auto &diagnostic : diagnostics) { result.diagnostic.push_back(CreateDiagnosticForError(context, *diagnostic)); diff --git a/ets2panda/lsp/src/completions.cpp b/ets2panda/lsp/src/completions.cpp index fc0e486bf6fb59eaf424608bdf51a6fae79b5179..3aab5ee26f607b677456cd9cb39dbc49ba69c888 100644 --- a/ets2panda/lsp/src/completions.cpp +++ b/ets2panda/lsp/src/completions.cpp @@ -704,7 +704,7 @@ CompletionEntry InitEntry(const ir::AstNode *decl) return child->IsAssignmentExpression() && child->AsAssignmentExpression()->Left()->IsIdentifier() && child->AsAssignmentExpression()->Left()->AsIdentifier()->ToString() == name; }); - if (found != nullptr) { + if (found != nullptr && !decl->AsClassProperty()->IsConst()) { // let variable in global definition need to be assigned in _$init$_ method kind = CompletionEntryKind::VARIABLE; } else { diff --git a/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_as_type09.ets b/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_as_type09.ets index 0aaa1cd95c12b46781c38e8fe04323d9b3e4cfbf..d4241e233d8122a0cae4402575c1b0eb486f26c3 100644 --- a/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_as_type09.ets +++ b/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_as_type09.ets @@ -18,4 +18,5 @@ let a = 1 as MyAnno +/* @@? 19:9 Error TypeError: Annotations cannot be used as a type. */ /* @@? 19:14 Error TypeError: Annotations cannot be used as a type. */ diff --git a/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_duplicate_on_extension_lambda.ets b/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_duplicate_on_extension_lambda.ets index 025b88d8e8e040134856aa20c860271ac76c64c1..6c300bd3060d2617dd4c068c8b8e298c486245be 100644 --- a/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_duplicate_on_extension_lambda.ets +++ b/ets2panda/test/ast/compiler/ets/annotation_tests/annotationUsage_duplicate_on_extension_lambda.ets @@ -18,7 +18,8 @@ class A { name = "Bob" } let a = new A(); -let show = @Anno()@/* @@ label */Anno(this: A): string => { +let show = @Anno()@/* @@ label */Anno/*@@ label2 */(this: A): string => { return "Hello," + this.name; } /* @@@ label Error TypeError: Duplicate annotations are not allowed. The annotation 'Anno' has already been applied to this element. */ +/* @@@ label2 Error TypeError: Duplicate annotations are not allowed. The annotation 'Anno' has already been applied to this element. */ diff --git a/ets2panda/test/ast/compiler/ets/circular_variable_init.ets b/ets2panda/test/ast/compiler/ets/circular_variable_init.ets index af59760eb594df83e7d67056e00a8ef05a348a7c..fc6881da7f2ee8bf16964c5c552197dffa291df7 100644 --- a/ets2panda/test/ast/compiler/ets/circular_variable_init.ets +++ b/ets2panda/test/ast/compiler/ets/circular_variable_init.ets @@ -47,7 +47,7 @@ function main() { /* @@? 23:19 Error TypeError: Circular dependency detected for identifier: b */ /* @@? 31:15 Error TypeError: Unresolved reference globalb */ /* @@? 33:5 Error TypeError: Circular dependency detected for identifier: globalc */ -/* @@? 37:7 Error TypeError: Circular dependency detected for identifier: constb */ +/* @@? 36:7 Error TypeError: Circular dependency detected for identifier: consta */ /* @@? 40:17 Error TypeError: Unresolved reference mainb */ /* @@? 42:17 Error TypeError: Variable 'maind' is accessed before it's initialization. */ /* @@? 43:9 Error TypeError: Circular dependency detected for identifier: maind */ diff --git a/ets2panda/test/ast/compiler/ets/namespace_tests/namespace_as_type09.ets b/ets2panda/test/ast/compiler/ets/namespace_tests/namespace_as_type09.ets index 34b0e476d3ec5b3b5765b22e98acc2e3e4ec0fc0..5b1dfbb4d5673bf61317715200a6f05ee5cfc5de 100644 --- a/ets2panda/test/ast/compiler/ets/namespace_tests/namespace_as_type09.ets +++ b/ets2panda/test/ast/compiler/ets/namespace_tests/namespace_as_type09.ets @@ -18,4 +18,5 @@ namespace MySpace { let a = 1 as MySpace +/* @@? 19:9 Error TypeError: Namespace 'MySpace' cannot be used as a type. */ /* @@? 19:14 Error TypeError: Namespace 'MySpace' cannot be used as a type. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.ets index 44730b44be644f563c713caf76cf382396764f2b..c3d7a882b0105811a0a24594577ebb9f81f75719 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.ets @@ -20,5 +20,6 @@ const invalidUsage1 = @Log("value")) ()=>{} /* @@? 19:24 Error TypeError: Annotations without 'SOURCE' cannot be used on lambda expressions, local declarations, or types. */ /* @@? 19:36 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:36 Error TypeError: Annotations without 'SOURCE' cannot be used on lambda expressions, local declarations, or types. */ /* @@? 19:40 Error SyntaxError: Unexpected token '=>'. */ /* @@? 19:40 Error SyntaxError: Unexpected token. */ diff --git a/ets2panda/test/compiler/ets/lambda_infer_type/lambda_infer_type_scope-expected.txt b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_infer_type_scope-expected.txt index cf65a444be5ce78de5a3e60473e06389e6c6d74f..3622381651f4710e92a111d3303dc21d068be2cd 100644 --- a/ets2panda/test/compiler/ets/lambda_infer_type/lambda_infer_type_scope-expected.txt +++ b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_infer_type_scope-expected.txt @@ -624,14 +624,14 @@ }, "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 17, + "column": 9, + "program": "lambda_infer_type_scope.ets" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 17, + "column": 29, + "program": "lambda_infer_type_scope.ets" } } }, diff --git a/ets2panda/test/compiler/ets/loopWithinLambda-expected.txt b/ets2panda/test/compiler/ets/loopWithinLambda-expected.txt index 2dffdc1e5b14a857ef23b7538d1cad30ea8be2e7..812505c75682f8dadfbbbe07531c730e94f7f75d 100644 --- a/ets2panda/test/compiler/ets/loopWithinLambda-expected.txt +++ b/ets2panda/test/compiler/ets/loopWithinLambda-expected.txt @@ -519,7 +519,956 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "F1", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 20, + "column": 9, + "program": "loopWithinLambda.ets" + } + } + }, + "right": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "counter", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 27, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 20, + "column": 30, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 18, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 20, + "column": 30, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 18, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 20, + "column": 30, + "program": "loopWithinLambda.ets" + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "funcWithLambda", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T1", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 25, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 27, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 25, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 29, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 25, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 29, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 9, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 23, + "program": "loopWithinLambda.ets" + } + } + }, + "init": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "lambda", + "typeAnnotation": { + "type": "ETSFunctionType", + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "arg", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 45, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 48, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 40, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 48, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 40, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 48, + "program": "loopWithinLambda.ets" + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 53, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 56, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 39, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 56, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 31, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 56, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 31, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 56, + "program": "loopWithinLambda.ets" + } + } + }, + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "arg", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 63, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 66, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 58, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 66, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 58, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 66, + "program": "loopWithinLambda.ets" + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "lambda", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 80, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 86, + "program": "loopWithinLambda.ets" + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "arg", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 87, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 90, + "program": "loopWithinLambda.ets" + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 80, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 91, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 73, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 91, + "program": "loopWithinLambda.ets" + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 71, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 93, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 30, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 93, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 30, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 93, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 9, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 93, + "program": "loopWithinLambda.ets" + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 21, + "column": 5, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 21, + "column": 93, + "program": "loopWithinLambda.ets" + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "it", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T2", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 15, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 17, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 17, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 9, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 11, + "program": "loopWithinLambda.ets" + } + } + }, + "init": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "c", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 22, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 25, + "program": "loopWithinLambda.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 19, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 25, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 19, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 25, + "program": "loopWithinLambda.ets" + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 28, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 31, + "program": "loopWithinLambda.ets" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 43, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 44, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 36, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 44, + "program": "loopWithinLambda.ets" + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 35, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 45, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 18, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 45, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 18, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 45, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 9, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 45, + "program": "loopWithinLambda.ets" + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 22, + "column": 5, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 22, + "column": 45, + "program": "loopWithinLambda.ets" + } + } + }, + { + "type": "WhileStatement", + "test": { + "type": "BinaryExpression", + "operator": ">", + "left": { + "type": "Identifier", + "name": "counter", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 12, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 19, + "program": "loopWithinLambda.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 24, + "column": 22, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 23, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 12, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 23, + "program": "loopWithinLambda.ets" + } + } + }, + "body": { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "counter", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 25, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 32, + "program": "loopWithinLambda.ets" + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "funcWithLambda", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 35, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 49, + "program": "loopWithinLambda.ets" + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "it", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 50, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 52, + "program": "loopWithinLambda.ets" + } + } + }, + { + "type": "Identifier", + "name": "counter", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 54, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 61, + "program": "loopWithinLambda.ets" + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 35, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 62, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 25, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 62, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 25, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 62, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 24, + "column": 62, + "program": "loopWithinLambda.ets" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 35, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 25, + "column": 2, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 17, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 25, + "column": 2, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 17, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 25, + "column": 2, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 25, + "column": 2, + "program": "loopWithinLambda.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "loopWithinLambda.ets" + }, + "end": { + "line": 25, + "column": 2, + "program": "loopWithinLambda.ets" + } + } + } + ], "loc": { "start": { "line": 1, @@ -672,12 +1621,12 @@ "loc": { "start": { "line": 21, - "column": 25, + "column": 9, "program": "loopWithinLambda.ets" }, "end": { "line": 21, - "column": 27, + "column": 23, "program": "loopWithinLambda.ets" } } @@ -685,12 +1634,12 @@ "loc": { "start": { "line": 21, - "column": 25, + "column": 9, "program": "loopWithinLambda.ets" }, "end": { "line": 21, - "column": 29, + "column": 23, "program": "loopWithinLambda.ets" } } @@ -698,12 +1647,12 @@ "loc": { "start": { "line": 21, - "column": 25, + "column": 9, "program": "loopWithinLambda.ets" }, "end": { "line": 21, - "column": 29, + "column": 23, "program": "loopWithinLambda.ets" } } @@ -805,7 +1754,7 @@ "loc": { "start": { "line": 21, - "column": 39, + "column": 31, "program": "loopWithinLambda.ets" }, "end": { @@ -964,7 +1913,7 @@ "loc": { "start": { "line": 21, - "column": 71, + "column": 30, "program": "loopWithinLambda.ets" }, "end": { @@ -1047,12 +1996,12 @@ "loc": { "start": { "line": 22, - "column": 13, + "column": 9, "program": "loopWithinLambda.ets" }, "end": { "line": 22, - "column": 15, + "column": 11, "program": "loopWithinLambda.ets" } } @@ -1060,12 +2009,12 @@ "loc": { "start": { "line": 22, - "column": 13, + "column": 9, "program": "loopWithinLambda.ets" }, "end": { "line": 22, - "column": 17, + "column": 11, "program": "loopWithinLambda.ets" } } @@ -1073,12 +2022,12 @@ "loc": { "start": { "line": 22, - "column": 13, + "column": 9, "program": "loopWithinLambda.ets" }, "end": { "line": 22, - "column": 17, + "column": 11, "program": "loopWithinLambda.ets" } } @@ -1208,7 +2157,7 @@ "loc": { "start": { "line": 22, - "column": 35, + "column": 18, "program": "loopWithinLambda.ets" }, "end": { @@ -1457,7 +2406,7 @@ "loc": { "start": { "line": 20, - "column": 35, + "column": 17, "program": "loopWithinLambda.ets" }, "end": { diff --git a/ets2panda/test/compiler/ets/tuple_types_13-expected.txt b/ets2panda/test/compiler/ets/tuple_types_13-expected.txt index 014a48229801a92b2001315036164b18d0c74ee6..72526f212a3449d14356f9cf1a2190a8d72daa88 100644 --- a/ets2panda/test/compiler/ets/tuple_types_13-expected.txt +++ b/ets2panda/test/compiler/ets/tuple_types_13-expected.txt @@ -371,7 +371,138 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "tup_2", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 7, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 19, + "column": 12, + "program": "tuple_types_13.ets" + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 13, + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 20, + "column": 8, + "program": "tuple_types_13.ets" + } + } + }, + { + "type": "StringLiteral", + "value": "A", + "loc": { + "start": { + "line": 20, + "column": 10, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 20, + "column": 13, + "program": "tuple_types_13.ets" + } + } + }, + { + "type": "StringLiteral", + "value": "D", + "loc": { + "start": { + "line": 20, + "column": 15, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 20, + "column": 18, + "program": "tuple_types_13.ets" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 5, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 20, + "column": 19, + "program": "tuple_types_13.ets" + } + } + } + ], + "loc": { + "start": { + "line": 19, + "column": 30, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 21, + "column": 2, + "program": "tuple_types_13.ets" + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 7, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 21, + "column": 2, + "program": "tuple_types_13.ets" + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 7, + "program": "tuple_types_13.ets" + }, + "end": { + "line": 21, + "column": 2, + "program": "tuple_types_13.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/FunctionalTypeAsTypeArgument-expected.txt b/ets2panda/test/parser/ets/FunctionalTypeAsTypeArgument-expected.txt index d2da9e851fad9143369149915dbdea0aa5b09a14..e730cd38e21b49510eafae8dab9c1316e811b660 100644 --- a/ets2panda/test/parser/ets/FunctionalTypeAsTypeArgument-expected.txt +++ b/ets2panda/test/parser/ets/FunctionalTypeAsTypeArgument-expected.txt @@ -181,7 +181,247 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "alma", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 11, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "right": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Array", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 18, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 23, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSFunctionType", + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "args", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 31, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 37, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 31, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 31, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 25, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 25, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 42, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 46, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 46, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 23, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 47, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 18, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 48, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 18, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 16, + "column": 48, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 17, + "column": 1, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 17, + "column": 1, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "FunctionalTypeAsTypeArgument.ets" + }, + "end": { + "line": 17, + "column": 1, + "program": "FunctionalTypeAsTypeArgument.ets" + } + } + } + ], "loc": { "start": { "line": 1, @@ -382,12 +622,12 @@ "loc": { "start": { "line": 16, - "column": 24, + "column": 23, "program": "FunctionalTypeAsTypeArgument.ets" }, "end": { "line": 16, - "column": 46, + "column": 47, "program": "FunctionalTypeAsTypeArgument.ets" } } diff --git a/ets2panda/test/parser/ets/assign-expected.txt b/ets2panda/test/parser/ets/assign-expected.txt index b6142a48972ef35b4edb2574709e83ec7de73e98..ecca7cc48137fc19df9aef1cd4afdb15ec84acec 100644 --- a/ets2panda/test/parser/ets/assign-expected.txt +++ b/ets2panda/test/parser/ets/assign-expected.txt @@ -139,6 +139,70 @@ "program": "assign.ets" } } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "assign.ets" + }, + "end": { + "line": 17, + "column": 8, + "program": "assign.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 11, + "program": "assign.ets" + }, + "end": { + "line": 17, + "column": 12, + "program": "assign.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "assign.ets" + }, + "end": { + "line": 17, + "column": 12, + "program": "assign.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "assign.ets" + }, + "end": { + "line": 17, + "column": 12, + "program": "assign.ets" + } + } } ], "loc": { diff --git a/ets2panda/test/parser/ets/boolean-expected.txt b/ets2panda/test/parser/ets/boolean-expected.txt index 152eb7b11c0667fae39d20210d8c1e29304593c7..7ada77b321648228a5131ab5dd1c32e006e27b70 100644 --- a/ets2panda/test/parser/ets/boolean-expected.txt +++ b/ets2panda/test/parser/ets/boolean-expected.txt @@ -245,6 +245,70 @@ "program": "boolean.ets" } } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "f", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "boolean.ets" + }, + "end": { + "line": 17, + "column": 8, + "program": "boolean.ets" + } + } + }, + "right": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 17, + "column": 11, + "program": "boolean.ets" + }, + "end": { + "line": 17, + "column": 16, + "program": "boolean.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "boolean.ets" + }, + "end": { + "line": 17, + "column": 16, + "program": "boolean.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "boolean.ets" + }, + "end": { + "line": 17, + "column": 16, + "program": "boolean.ets" + } + } } ], "loc": { diff --git a/ets2panda/test/parser/ets/const-expected.txt b/ets2panda/test/parser/ets/const-expected.txt index d4eb5c420cfb4764be6fdabe1548dbd7f8e58f35..5a4d86846cda72122ad449d577394170e666d9cc 100644 --- a/ets2panda/test/parser/ets/const-expected.txt +++ b/ets2panda/test/parser/ets/const-expected.txt @@ -181,7 +181,136 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "x", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "const.ets" + }, + "end": { + "line": 16, + "column": 8, + "program": "const.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 16, + "column": 11, + "program": "const.ets" + }, + "end": { + "line": 16, + "column": 12, + "program": "const.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "const.ets" + }, + "end": { + "line": 16, + "column": 12, + "program": "const.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "const.ets" + }, + "end": { + "line": 16, + "column": 12, + "program": "const.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "y", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "const.ets" + }, + "end": { + "line": 17, + "column": 8, + "program": "const.ets" + } + } + }, + "right": { + "type": "StringLiteral", + "value": "Hello", + "loc": { + "start": { + "line": 17, + "column": 19, + "program": "const.ets" + }, + "end": { + "line": 17, + "column": 26, + "program": "const.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "const.ets" + }, + "end": { + "line": 17, + "column": 26, + "program": "const.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "const.ets" + }, + "end": { + "line": 17, + "column": 26, + "program": "const.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/decl_infer-expected.txt b/ets2panda/test/parser/ets/decl_infer-expected.txt index d019542239551efc0eb95ca02e7f0f43516c6bcc..157edcb8fb81ad0ccb1557120ca0328c7f57599d 100644 --- a/ets2panda/test/parser/ets/decl_infer-expected.txt +++ b/ets2panda/test/parser/ets/decl_infer-expected.txt @@ -501,6 +501,326 @@ "program": "decl_infer.ets" } } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "ci", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 22, + "column": 9, + "program": "decl_infer.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 22, + "column": 12, + "program": "decl_infer.ets" + }, + "end": { + "line": 22, + "column": 13, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 22, + "column": 13, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 22, + "column": 13, + "program": "decl_infer.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "cd", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 23, + "column": 9, + "program": "decl_infer.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 23, + "column": 12, + "program": "decl_infer.ets" + }, + "end": { + "line": 23, + "column": 15, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 23, + "column": 15, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 23, + "column": 15, + "program": "decl_infer.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "cc", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 24, + "column": 9, + "program": "decl_infer.ets" + } + } + }, + "right": { + "type": "CharLiteral", + "value": "a", + "loc": { + "start": { + "line": 24, + "column": 12, + "program": "decl_infer.ets" + }, + "end": { + "line": 24, + "column": 16, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 24, + "column": 16, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 24, + "column": 16, + "program": "decl_infer.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "cs", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 25, + "column": 9, + "program": "decl_infer.ets" + } + } + }, + "right": { + "type": "StringLiteral", + "value": "11", + "loc": { + "start": { + "line": 25, + "column": 12, + "program": "decl_infer.ets" + }, + "end": { + "line": 25, + "column": 16, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 25, + "column": 16, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 25, + "column": 16, + "program": "decl_infer.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "cb", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 26, + "column": 9, + "program": "decl_infer.ets" + } + } + }, + "right": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 26, + "column": 12, + "program": "decl_infer.ets" + }, + "end": { + "line": 26, + "column": 17, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 26, + "column": 17, + "program": "decl_infer.ets" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 7, + "program": "decl_infer.ets" + }, + "end": { + "line": 26, + "column": 17, + "program": "decl_infer.ets" + } + } } ], "loc": { diff --git a/ets2panda/test/parser/ets/exports-expected.txt b/ets2panda/test/parser/ets/exports-expected.txt index 774017d3bbef04aa72825b8ac1457c99191e2b76..442f2b93db94cd86d9827c59302e07af845bc656 100644 --- a/ets2panda/test/parser/ets/exports-expected.txt +++ b/ets2panda/test/parser/ets/exports-expected.txt @@ -496,6 +496,70 @@ "program": "exports.ets" } } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 14, + "program": "exports.ets" + }, + "end": { + "line": 17, + "column": 15, + "program": "exports.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 12, + "loc": { + "start": { + "line": 17, + "column": 18, + "program": "exports.ets" + }, + "end": { + "line": 17, + "column": 20, + "program": "exports.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 14, + "program": "exports.ets" + }, + "end": { + "line": 17, + "column": 20, + "program": "exports.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 14, + "program": "exports.ets" + }, + "end": { + "line": 17, + "column": 20, + "program": "exports.ets" + } + } } ], "loc": { diff --git a/ets2panda/test/parser/ets/global_const_vars3-expected.txt b/ets2panda/test/parser/ets/global_const_vars3-expected.txt index 03532089003d8b41bb581d0b4bc225bf2026d151..93edc541b8e30e8b17338af8a6ee225a91890f11 100644 --- a/ets2panda/test/parser/ets/global_const_vars3-expected.txt +++ b/ets2panda/test/parser/ets/global_const_vars3-expected.txt @@ -689,7 +689,183 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 16, + "column": 8, + "program": "global_const_vars3.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 16, + "column": 16, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 16, + "column": 17, + "program": "global_const_vars3.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 16, + "column": 17, + "program": "global_const_vars3.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 16, + "column": 17, + "program": "global_const_vars3.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "dae", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 10, + "program": "global_const_vars3.ets" + } + } + }, + "right": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Date", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 23, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 27, + "program": "global_const_vars3.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 23, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 28, + "program": "global_const_vars3.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 23, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 28, + "program": "global_const_vars3.ets" + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 17, + "column": 19, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 30, + "program": "global_const_vars3.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 30, + "program": "global_const_vars3.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "global_const_vars3.ets" + }, + "end": { + "line": 17, + "column": 30, + "program": "global_const_vars3.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_1-expected.txt b/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_1-expected.txt index 2e79b56dc3ff735c402ae9f4ebeabf7cd28bdddf..7110030c74d72fc95124875d25d59e0169c80110 100644 --- a/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_1-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_1-expected.txt @@ -547,6 +547,70 @@ "body": { "type": "BlockStatement", "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "dbl", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "imported_module_1.ets" + }, + "end": { + "line": 16, + "column": 17, + "program": "imported_module_1.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1.23457, + "loc": { + "start": { + "line": 16, + "column": 28, + "program": "imported_module_1.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "imported_module_1.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "imported_module_1.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "imported_module_1.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "imported_module_1.ets" + }, + "end": { + "line": 16, + "column": 38, + "program": "imported_module_1.ets" + } + } + }, { "type": "ExpressionStatement", "expression": { diff --git a/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_2-expected.txt b/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_2-expected.txt index 0f0b79893122df041613b015175524007968a109..e782f6cf9d62ad3c60f9eb675a3cf64843c170bc 100644 --- a/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_2-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/import_name_conflicts/imported_module_2-expected.txt @@ -547,6 +547,70 @@ "body": { "type": "BlockStatement", "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "flt", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "imported_module_2.ets" + }, + "end": { + "line": 16, + "column": 17, + "program": "imported_module_2.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 2.345, + "loc": { + "start": { + "line": 16, + "column": 27, + "program": "imported_module_2.ets" + }, + "end": { + "line": 16, + "column": 32, + "program": "imported_module_2.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "imported_module_2.ets" + }, + "end": { + "line": 16, + "column": 32, + "program": "imported_module_2.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14, + "program": "imported_module_2.ets" + }, + "end": { + "line": 16, + "column": 32, + "program": "imported_module_2.ets" + } + } + }, { "type": "ExpressionStatement", "expression": { diff --git a/ets2panda/test/parser/ets/import_tests/packages/package_module_1-expected.txt b/ets2panda/test/parser/ets/import_tests/packages/package_module_1-expected.txt old mode 100755 new mode 100644 index b2003212002cfd90f02b6e95f55be89e306fd67b..2d5c4ca9b445de8e80711e1bd8ead7df6ead535d --- a/ets2panda/test/parser/ets/import_tests/packages/package_module_1-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/packages/package_module_1-expected.txt @@ -139,7 +139,136 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "dbl", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 17, + "program": "package_module_1.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1.23457, + "loc": { + "start": { + "line": 18, + "column": 28, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 38, + "program": "package_module_1.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 38, + "program": "package_module_1.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 38, + "program": "package_module_1.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "flt", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 17, + "program": "package_module_2.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1.2345, + "loc": { + "start": { + "line": 18, + "column": 27, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 33, + "program": "package_module_2.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 33, + "program": "package_module_2.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 33, + "program": "package_module_2.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/import_tests/packages/package_module_2-expected.txt b/ets2panda/test/parser/ets/import_tests/packages/package_module_2-expected.txt old mode 100755 new mode 100644 index b1d61276d998f51f6b8cece64749b90610cecfc8..f4d8519548b7c4daa0e3be6f420290c57487f40c --- a/ets2panda/test/parser/ets/import_tests/packages/package_module_2-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/packages/package_module_2-expected.txt @@ -139,7 +139,136 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "flt", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 17, + "program": "package_module_2.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1.2345, + "loc": { + "start": { + "line": 18, + "column": 27, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 33, + "program": "package_module_2.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 33, + "program": "package_module_2.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_2.ets" + }, + "end": { + "line": 18, + "column": 33, + "program": "package_module_2.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "dbl", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 17, + "program": "package_module_1.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1.23457, + "loc": { + "start": { + "line": 18, + "column": 28, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 34, + "program": "package_module_1.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 34, + "program": "package_module_1.ets" + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14, + "program": "package_module_1.ets" + }, + "end": { + "line": 18, + "column": 34, + "program": "package_module_1.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/launch_with_call_expression-expected.txt b/ets2panda/test/parser/ets/launch_with_call_expression-expected.txt index d242fffc6c67d90898f9a970bef232ad11c4b50b..d1b22a7214d798e8fd0f5d2b7a9ebdc269909ca7 100644 --- a/ets2panda/test/parser/ets/launch_with_call_expression-expected.txt +++ b/ets2panda/test/parser/ets/launch_with_call_expression-expected.txt @@ -825,14 +825,14 @@ }, "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 21, + "column": 17, + "program": "launch_with_call_expression.ets" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 21, + "column": 35, + "program": "launch_with_call_expression.ets" } } } diff --git a/ets2panda/test/parser/ets/literals-expected.txt b/ets2panda/test/parser/ets/literals-expected.txt index 5dffbbbbf62629a9dc45140ad69982e1902a4991..0b5923cbd2ed5bd8ea267c812bb4d4168fb3c735 100644 --- a/ets2panda/test/parser/ets/literals-expected.txt +++ b/ets2panda/test/parser/ets/literals-expected.txt @@ -181,7 +181,1499 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit00", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 16, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 16, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 16, + "column": 16, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 16, + "column": 16, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 16, + "column": 16, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit01", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 17, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 17, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 17, + "column": 18, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 17, + "column": 18, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 17, + "column": 18, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit03", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 20, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "StringLiteral", + "value": "string", + "loc": { + "start": { + "line": 20, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 20, + "column": 23, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 20, + "column": 23, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 20, + "column": 23, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit04", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 21, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 11, + "loc": { + "start": { + "line": 21, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 21, + "column": 21, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 21, + "column": 21, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 21, + "column": 21, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit05", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 22, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 3.14159, + "loc": { + "start": { + "line": 22, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 22, + "column": 24, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 22, + "column": 24, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 22, + "column": 24, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit06", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 23, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1e-06, + "loc": { + "start": { + "line": 23, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 23, + "column": 21, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 23, + "column": 21, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 23, + "column": 21, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit07", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 24, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1e-06, + "loc": { + "start": { + "line": 24, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 24, + "column": 21, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 24, + "column": 21, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 24, + "column": 21, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit08", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 25, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": -1e-06, + "loc": { + "start": { + "line": 25, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 25, + "column": 22, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 25, + "column": 22, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 25, + "column": 22, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit09", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 26, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "CharLiteral", + "value": "a", + "loc": { + "start": { + "line": 26, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 26, + "column": 19, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 26, + "column": 19, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 26, + "column": 19, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit10", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 27, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "CharLiteral", + "value": "a", + "loc": { + "start": { + "line": 27, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 27, + "column": 24, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 27, + "column": 24, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 27, + "column": 24, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit11", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 28, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "BooleanLiteral", + "value": true, + "loc": { + "start": { + "line": 28, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 28, + "column": 19, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 28, + "column": 19, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 28, + "column": 19, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit12", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 29, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 29, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 29, + "column": 20, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 29, + "column": 20, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 29, + "column": 20, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit13", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 30, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 30, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 30, + "column": 19, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 30, + "column": 19, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 30, + "column": 19, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit14", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 31, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 123.45, + "loc": { + "start": { + "line": 31, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 31, + "column": 22, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 31, + "column": 22, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 31, + "column": 22, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit15", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 32, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1.2345e+12, + "loc": { + "start": { + "line": 32, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 32, + "column": 25, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 32, + "column": 25, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 32, + "column": 25, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit16", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 33, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": -123.45, + "loc": { + "start": { + "line": 33, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 33, + "column": 23, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 33, + "column": 23, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 33, + "column": 23, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit17", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 34, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": -1.2345e+12, + "loc": { + "start": { + "line": 34, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 34, + "column": 26, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 34, + "column": 26, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 34, + "column": 26, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit18", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 35, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [], + "loc": { + "start": { + "line": 35, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 35, + "column": 17, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 35, + "column": 17, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 35, + "column": 17, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit19", + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 36, + "column": 16, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 17, + "program": "literals.ets" + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 36, + "column": 18, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 19, + "program": "literals.ets" + } + } + }, + { + "type": "NumberLiteral", + "value": 3, + "loc": { + "start": { + "line": 36, + "column": 20, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 21, + "program": "literals.ets" + } + } + } + ], + "loc": { + "start": { + "line": 36, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 22, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 36, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 22, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 36, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 36, + "column": 22, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit20", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 37, + "column": 16, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 19, + "program": "literals.ets" + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 37, + "column": 20, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 23, + "program": "literals.ets" + } + } + }, + { + "type": "StringLiteral", + "value": "3", + "loc": { + "start": { + "line": 37, + "column": 24, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 27, + "program": "literals.ets" + } + } + } + ], + "loc": { + "start": { + "line": 37, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 28, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 28, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 37, + "column": 28, + "program": "literals.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "lit21", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 12, + "program": "literals.ets" + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 38, + "column": 16, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 19, + "program": "literals.ets" + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 38, + "column": 20, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 23, + "program": "literals.ets" + } + } + }, + { + "type": "NumberLiteral", + "value": 3, + "loc": { + "start": { + "line": 38, + "column": 24, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 27, + "program": "literals.ets" + } + } + } + ], + "loc": { + "start": { + "line": 38, + "column": 15, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 28, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 28, + "program": "literals.ets" + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 7, + "program": "literals.ets" + }, + "end": { + "line": 38, + "column": 28, + "program": "literals.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/null_valid-expected.txt b/ets2panda/test/parser/ets/null_valid-expected.txt index f4d0b80cdb143ef46de7c502def756f237e15ac5..54574e7badc86ac9fe2c918f7a18df06241984d0 100644 --- a/ets2panda/test/parser/ets/null_valid-expected.txt +++ b/ets2panda/test/parser/ets/null_valid-expected.txt @@ -182,6 +182,70 @@ "body": { "type": "BlockStatement", "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "null_valid.ets" + }, + "end": { + "line": 16, + "column": 8, + "program": "null_valid.ets" + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 16, + "column": 11, + "program": "null_valid.ets" + }, + "end": { + "line": 16, + "column": 15, + "program": "null_valid.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "null_valid.ets" + }, + "end": { + "line": 16, + "column": 15, + "program": "null_valid.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "null_valid.ets" + }, + "end": { + "line": 16, + "column": 15, + "program": "null_valid.ets" + } + } + }, { "type": "ExpressionStatement", "expression": { diff --git a/ets2panda/test/parser/ets/tupleIndexWithNumbers-expected.txt b/ets2panda/test/parser/ets/tupleIndexWithNumbers-expected.txt index f72997ce91c0e8c163c7518cf60103b9bdcbefd3..b060c514ff1b2d5e0f0cc2de8fc56ecf50a4648c 100644 --- a/ets2panda/test/parser/ets/tupleIndexWithNumbers-expected.txt +++ b/ets2panda/test/parser/ets/tupleIndexWithNumbers-expected.txt @@ -75,7 +75,136 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "index1", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 16, + "column": 13, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 16, + "column": 21, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 16, + "column": 22, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 16, + "column": 22, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 7, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 16, + "column": 22, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "index2", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 17, + "column": 13, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 22, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 17, + "column": 23, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 17, + "column": 23, + "program": "tupleIndexWithNumbers.ets" + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7, + "program": "tupleIndexWithNumbers.ets" + }, + "end": { + "line": 17, + "column": 23, + "program": "tupleIndexWithNumbers.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/type_variance1-expected.txt b/ets2panda/test/parser/ets/type_variance1-expected.txt index d129a48009641db72e39ed3c032ed04e4fec9acc..1079702a499e87222f6d3acc81f4a5fe2f4198c1 100644 --- a/ets2panda/test/parser/ets/type_variance1-expected.txt +++ b/ets2panda/test/parser/ets/type_variance1-expected.txt @@ -2163,7 +2163,247 @@ "params": [], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "C_GLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 15, + "program": "type_variance1.ets" + } + } + }, + "right": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 35, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 36, + "program": "type_variance1.ets" + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Array", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "type_variance1.ets" + }, + "end": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + }, + "end": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + }, + "end": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + }, + "end": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + }, + "end": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "type_variance1.ets" + }, + "end": { + "line": 1, + "column": 3, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 43, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 45, + "program": "type_variance1.ets" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 36, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 46, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 35, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 47, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 35, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 47, + "program": "type_variance1.ets" + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 20, + "column": 31, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 49, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 49, + "program": "type_variance1.ets" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7, + "program": "type_variance1.ets" + }, + "end": { + "line": 20, + "column": 49, + "program": "type_variance1.ets" + } + } + } + ], "loc": { "start": { "line": 1, diff --git a/ets2panda/test/parser/ets/unary_op-expected.txt b/ets2panda/test/parser/ets/unary_op-expected.txt index 10516d0b64527f41a9159f8e30e62c2ac679e95b..66a9fa021cbe29d61455bee1d944bfb1d5f9c58d 100644 --- a/ets2panda/test/parser/ets/unary_op-expected.txt +++ b/ets2panda/test/parser/ets/unary_op-expected.txt @@ -801,6 +801,70 @@ } } }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "unary_op.ets" + }, + "end": { + "line": 24, + "column": 8, + "program": "unary_op.ets" + } + } + }, + "right": { + "type": "BooleanLiteral", + "value": true, + "loc": { + "start": { + "line": 24, + "column": 11, + "program": "unary_op.ets" + }, + "end": { + "line": 24, + "column": 15, + "program": "unary_op.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "unary_op.ets" + }, + "end": { + "line": 24, + "column": 15, + "program": "unary_op.ets" + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7, + "program": "unary_op.ets" + }, + "end": { + "line": 24, + "column": 15, + "program": "unary_op.ets" + } + } + }, { "type": "ExpressionStatement", "expression": { diff --git a/ets2panda/test/runtime/ets/lambda_inner_call_static_method.ets b/ets2panda/test/runtime/ets/lambda_inner_call_static_method.ets index 5214be0372009ff27813310ec04f2f704dc26b17..b3c0a605e24ba64b353ff62667f533644b7cb9bc 100644 --- a/ets2panda/test/runtime/ets/lambda_inner_call_static_method.ets +++ b/ets2panda/test/runtime/ets/lambda_inner_call_static_method.ets @@ -15,7 +15,7 @@ function foo(callback: () => string) { } -const bar = (): string => { +const bar: () => string = (): string => { return A.fob(); } diff --git a/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit1.ets b/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit1.ets new file mode 100644 index 0000000000000000000000000000000000000000..dcce7c3868c7b855983b0237c2fe6272ced5c3ce --- /dev/null +++ b/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit1.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class A { } + +class B { } + +let a: A = new A() + +let b: B = new B() + +const c: [A, B] = [a, b]; + +function main() { + assertEQ(c[0], a) + assertEQ(c[1], b) +} + diff --git a/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit2.ets b/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit2.ets new file mode 100644 index 0000000000000000000000000000000000000000..35ed39814b109e9dbfda37b8b4260026575b92ec --- /dev/null +++ b/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit2.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class A { } + +class B { } + +let a: A = new A() + +let b: B = new B() + +const c: [Object, Object] = [a, b]; + +let d = c; + +function main() { + assertEQ(c[0], a) + assertEQ(c[1], b) + + assertEQ(d[0], a) + assertEQ(d[1], b) +} + diff --git a/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit_Lambda.ets b/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit_Lambda.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb1cae5f8d64adcd5ad871d83f3c977fdfb2279c --- /dev/null +++ b/ets2panda/test/runtime/ets/topLevelInitOrder/topLevelInit_Lambda.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let x = (s: string)=>{ + return s; +} + +function main() { + assertEQ(x("hello"), "hello"); +} diff --git a/ets2panda/test/unit/lsp/get_diagnostics.cpp b/ets2panda/test/unit/lsp/get_diagnostics.cpp index bfb46178f156eaba388b33ca9cf3ed228c8ad33f..0c9b1d6815e63a2441a1c443bca74b6695d44489 100644 --- a/ets2panda/test/unit/lsp/get_diagnostics.cpp +++ b/ets2panda/test/unit/lsp/get_diagnostics.cpp @@ -51,31 +51,32 @@ add("1", 2);)"); initializer.DestroyContext(ctx); auto const expectedErrorCount = 3; ASSERT_EQ(result.diagnostic.size(), expectedErrorCount); - auto const thirdIndex = 2; + auto const firstIndex = 0; auto const expectedFirstStartLine = 1; auto const expectedFirstStartCharacter = 19; auto const expectedFirstEndLine = 1; auto const expectedFirstEndCharacter = 26; - ASSERT_EQ(result.diagnostic[thirdIndex].range_.start.line_, expectedFirstStartLine); - ASSERT_EQ(result.diagnostic[thirdIndex].range_.start.character_, expectedFirstStartCharacter); - ASSERT_EQ(result.diagnostic[thirdIndex].range_.end.line_, expectedFirstEndLine); - ASSERT_EQ(result.diagnostic[thirdIndex].range_.end.character_, expectedFirstEndCharacter); - ASSERT_EQ(result.diagnostic[thirdIndex].severity_, DiagnosticSeverity::Error); - ASSERT_EQ(std::get(result.diagnostic[thirdIndex].code_), 1); - ASSERT_EQ(result.diagnostic[thirdIndex].message_, R"(Type '"hello"' cannot be assigned to type 'double')"); - ASSERT_EQ(result.diagnostic[thirdIndex].codeDescription_.href_, "test code description"); + ASSERT_EQ(result.diagnostic[firstIndex].range_.start.line_, expectedFirstStartLine); + ASSERT_EQ(result.diagnostic[firstIndex].range_.start.character_, expectedFirstStartCharacter); + ASSERT_EQ(result.diagnostic[firstIndex].range_.end.line_, expectedFirstEndLine); + ASSERT_EQ(result.diagnostic[firstIndex].range_.end.character_, expectedFirstEndCharacter); + ASSERT_EQ(result.diagnostic[firstIndex].severity_, DiagnosticSeverity::Error); + ASSERT_EQ(std::get(result.diagnostic[firstIndex].code_), 1); + ASSERT_EQ(result.diagnostic[firstIndex].message_, R"(Type '"hello"' cannot be assigned to type 'double')"); + ASSERT_EQ(result.diagnostic[firstIndex].codeDescription_.href_, "test code description"); + auto const thirdIndex = 2; auto const expectedSecondStartLine = 5; auto const expectedSecondStartCharacter = 5; auto const expectedSecondEndLine = 5; auto const expectedSecondEndCharacter = 8; - ASSERT_EQ(result.diagnostic[0].range_.start.line_, expectedSecondStartLine); - ASSERT_EQ(result.diagnostic[0].range_.start.character_, expectedSecondStartCharacter); - ASSERT_EQ(result.diagnostic[0].range_.end.line_, expectedSecondEndLine); - ASSERT_EQ(result.diagnostic[0].range_.end.character_, expectedSecondEndCharacter); - ASSERT_EQ(result.diagnostic[0].severity_, DiagnosticSeverity::Error); - ASSERT_EQ(std::get(result.diagnostic[0].code_), 1); - ASSERT_EQ(result.diagnostic[0].message_, R"(Type '"1"' is not compatible with type 'double' at index 1)"); - ASSERT_EQ(result.diagnostic[0].codeDescription_.href_, "test code description"); + ASSERT_EQ(result.diagnostic[thirdIndex].range_.start.line_, expectedSecondStartLine); + ASSERT_EQ(result.diagnostic[thirdIndex].range_.start.character_, expectedSecondStartCharacter); + ASSERT_EQ(result.diagnostic[thirdIndex].range_.end.line_, expectedSecondEndLine); + ASSERT_EQ(result.diagnostic[thirdIndex].range_.end.character_, expectedSecondEndCharacter); + ASSERT_EQ(result.diagnostic[thirdIndex].severity_, DiagnosticSeverity::Error); + ASSERT_EQ(std::get(result.diagnostic[thirdIndex].code_), 1); + ASSERT_EQ(result.diagnostic[thirdIndex].message_, R"(Type '"1"' is not compatible with type 'double' at index 1)"); + ASSERT_EQ(result.diagnostic[thirdIndex].codeDescription_.href_, "test code description"); } TEST_F(LspDiagnosticsTests, GetSyntacticDiagnostics1) @@ -105,7 +106,7 @@ let res = add(n, n);)"); LSPAPI const *lspApi = GetImpl(); auto result = lspApi->getSyntacticDiagnostics(ctx); initializer.DestroyContext(ctx); - auto const expectedErrorCount = 13; + auto const expectedErrorCount = 10; ASSERT_EQ(result.diagnostic.size(), expectedErrorCount); auto const expectedFirstStartLine = 1; auto const expectedFirstStartCharacter = 9; @@ -153,7 +154,7 @@ let res = add(n, n);)"); LSPAPI const *lspApi = GetImpl(); auto result = lspApi->getSyntacticDiagnostics(ctx); initializer.DestroyContext(ctx); - auto const forthIndex = 5; + auto const forthIndex = 4; auto const expectedForthStartLine = 1; auto const expectedForthStartCharacter = 22; auto const expectedForthEndLine = 1; @@ -166,7 +167,7 @@ let res = add(n, n);)"); ASSERT_EQ(std::get(result.diagnostic[forthIndex].code_), 1); ASSERT_EQ(result.diagnostic[forthIndex].message_, R"(Unexpected token ','.)"); ASSERT_EQ(result.diagnostic[forthIndex].codeDescription_.href_, "test code description"); - auto const fifthIndex = 8; + auto const fifthIndex = 6; auto const expectedFifththStartLine = 1; auto const expectedFifthStartCharacter = 27; auto const expectedFifthEndLine = 1; @@ -193,7 +194,7 @@ let res = add(n, n);)"); LSPAPI const *lspApi = GetImpl(); auto result = lspApi->getSyntacticDiagnostics(ctx); initializer.DestroyContext(ctx); - auto const sixthIndex = 9; + auto const sixthIndex = 7; auto const expectedSixthStartLine = 1; auto const expectedSixthStartCharacter = 33; auto const expectedSixthEndLine = 1; @@ -206,7 +207,7 @@ let res = add(n, n);)"); ASSERT_EQ(std::get(result.diagnostic[sixthIndex].code_), 1); ASSERT_EQ(result.diagnostic[sixthIndex].message_, R"(Unexpected token ')'.)"); ASSERT_EQ(result.diagnostic[sixthIndex].codeDescription_.href_, "test code description"); - auto const sevenIndex = 12; + auto const sevenIndex = 9; auto const expectedSeventhStartLine = 2; auto const expectedSeventhStartCharacter = 5; auto const expectedSeventhEndLine = 2; diff --git a/ets2panda/test/unit/lsp/inlay_hints_test.cpp b/ets2panda/test/unit/lsp/inlay_hints_test.cpp index 91d7532befeaf109f15590aa2ed0bd7a69549ce7..3e33e384f0325fed376ac6bc3ce857969e92ef43 100644 --- a/ets2panda/test/unit/lsp/inlay_hints_test.cpp +++ b/ets2panda/test/unit/lsp/inlay_hints_test.cpp @@ -213,8 +213,8 @@ TEST_F(LSPInlayHintsTests, VisitFunctionDeclarationLikeForReturnTypeTest1) )"}; const std::string doubleString = "double"; - const size_t addIndex = 89; - const size_t multiplyIndex = 186; + const size_t addIndex = 186; + const size_t multiplyIndex = 89; const size_t i0 = 0; const size_t i1 = 1; const size_t i2 = 2; @@ -257,8 +257,8 @@ TEST_F(LSPInlayHintsTests, VisitFunctionDeclarationLikeForReturnTypeTest2) const std::string voidString = "void"; const std::string stdString = "String"; - const size_t greetIndex = 95; - const size_t sayHelloIndex = 179; + const size_t greetIndex = 179; + const size_t sayHelloIndex = 95; const size_t i0 = 0; const size_t i1 = 1; const size_t i2 = 2; @@ -280,9 +280,9 @@ TEST_F(LSPInlayHintsTests, VisitFunctionDeclarationLikeForReturnTypeTest2) } return false; }); - ASSERT_EQ(result.hints[i2].text, stdString); + ASSERT_EQ(result.hints[i2].text, voidString); ASSERT_EQ(result.hints[i2].number, greetIndex); - ASSERT_EQ(result.hints[i3].text, voidString); + ASSERT_EQ(result.hints[i3].text, stdString); ASSERT_EQ(result.hints[i3].number, sayHelloIndex); initializer.DestroyContext(ctx); } diff --git a/ets2panda/test/unit/lsp/isolated_declaration.cpp b/ets2panda/test/unit/lsp/isolated_declaration.cpp index 5a0f1c776bba96cd364449bdb9ba54003c83cd59..290072080a98d54cd7a9df22395e86d8c2251e60 100644 --- a/ets2panda/test/unit/lsp/isolated_declaration.cpp +++ b/ets2panda/test/unit/lsp/isolated_declaration.cpp @@ -137,7 +137,7 @@ export const foo = () => { return childNode->IsIdentifier() && childNode->AsIdentifier()->Name() == "foo"; }); auto textChange = ark::es2panda::lsp::ProcessIdentifier(id->AsIdentifier(), checker, ctx->parserProgram); - const size_t expectedStart = 70; + const size_t expectedStart = 67; ASSERT_EQ(textChange.has_value(), true); ASSERT_EQ(textChange.value().newText, ": number | string"); ASSERT_EQ(textChange.value().span.start, expectedStart); diff --git a/ets2panda/util/diagnosticEngine.cpp b/ets2panda/util/diagnosticEngine.cpp index 9660f1f160f0261e55eee8caa904972c4c70247f..5d4f66e12d622744ea10a0a4b70d20a02f720e59 100644 --- a/ets2panda/util/diagnosticEngine.cpp +++ b/ets2panda/util/diagnosticEngine.cpp @@ -32,6 +32,15 @@ void CLIDiagnosticPrinter::Print(const DiagnosticBase &diagnostic) const std::cout << std::endl; } +void DiagnosticEngine::CleanDuplicateLog(DiagnosticType type) +{ + DiagnosticStorage &log = diagnostics_[type]; + std::sort(log.begin(), log.end(), [](const auto &lhs, const auto &rhs) { return *lhs < *rhs; }); + auto last = + std::unique(log.begin(), log.end(), [&](const auto &rhs, const auto &lhs) -> bool { return *rhs == *lhs; }); + log.resize(std::distance(log.begin(), last)); +} + const DiagnosticStorage &DiagnosticEngine::GetDiagnosticStorage(DiagnosticType type) { return diagnostics_[type]; diff --git a/ets2panda/util/diagnosticEngine.h b/ets2panda/util/diagnosticEngine.h index a013fc7a71296a28d869b92a28d67a00afe02e86..d2ad68446a6795299ede04640cf43a7739a30fa3 100644 --- a/ets2panda/util/diagnosticEngine.h +++ b/ets2panda/util/diagnosticEngine.h @@ -131,6 +131,8 @@ public: wError_ = wError; } + void CleanDuplicateLog(DiagnosticType type); + const DiagnosticStorage &GetDiagnosticStorage(DiagnosticType type); static void InitializeSignalHandlers();