diff --git a/src/ast/analysis/ComponentLookup.cpp b/src/ast/analysis/ComponentLookup.cpp index 8ba4b221e8e..20672d54877 100644 --- a/src/ast/analysis/ComponentLookup.cpp +++ b/src/ast/analysis/ComponentLookup.cpp @@ -44,7 +44,6 @@ const Component* ComponentLookupAnalysis::getComponent( // forward according to binding (we do not do this recursively on purpose) QualifiedName boundName = activeBinding.find(name); if (boundName.empty()) { - // compName is not bound to anything => just just compName boundName = name; } diff --git a/src/ast/transform/ComponentInstantiation.cpp b/src/ast/transform/ComponentInstantiation.cpp index 69567ae0b29..47962daa101 100644 --- a/src/ast/transform/ComponentInstantiation.cpp +++ b/src/ast/transform/ComponentInstantiation.cpp @@ -370,6 +370,8 @@ ComponentContent getInstantiatedContent(Program& program, const ComponentInit& c if (component == nullptr) { // this component is not defined => will trigger a semantic error + report.addError("Component " + componentInit.getComponentType()->getName() + " not found", + componentInit.getComponentType()->getSrcLoc()); return res; } diff --git a/tests/semantic/CMakeLists.txt b/tests/semantic/CMakeLists.txt index 02828eec6f7..8e795d409c4 100644 --- a/tests/semantic/CMakeLists.txt +++ b/tests/semantic/CMakeLists.txt @@ -271,3 +271,4 @@ negative_test(error_deduce_type) positive_output_stdout_test(output_stdout) positive_test(iteration_counter) positive_test(issue1896) +positive_test(comp_params) diff --git a/tests/semantic/comp_params/TopA.Foo.X.x.csv b/tests/semantic/comp_params/TopA.Foo.X.x.csv new file mode 100644 index 00000000000..f70f10e4db1 --- /dev/null +++ b/tests/semantic/comp_params/TopA.Foo.X.x.csv @@ -0,0 +1 @@ +A diff --git a/tests/semantic/comp_params/TopB.Foo.X.x.csv b/tests/semantic/comp_params/TopB.Foo.X.x.csv new file mode 100644 index 00000000000..223b7836fb1 --- /dev/null +++ b/tests/semantic/comp_params/TopB.Foo.X.x.csv @@ -0,0 +1 @@ +B diff --git a/tests/semantic/comp_params/comp_params.dl b/tests/semantic/comp_params/comp_params.dl new file mode 100644 index 00000000000..24b475f078d --- /dev/null +++ b/tests/semantic/comp_params/comp_params.dl @@ -0,0 +1,26 @@ + +.comp A { + .decl x(s:symbol) + x("A"). +} + +.comp B { + .decl x(s:symbol) + x("B"). +} + +.comp _Top { + + .comp _Foo : _Bar { + } + + .comp _Bar { + .init X = Q + .output X.x() + } + + .init Foo = _Foo +} + +.init TopA = _Top +.init TopB = _Top diff --git a/tests/semantic/comp_params/comp_params.err b/tests/semantic/comp_params/comp_params.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/semantic/comp_params/comp_params.out b/tests/semantic/comp_params/comp_params.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/semantic/comp_params_inheritance/comp_params_inheritance.err b/tests/semantic/comp_params_inheritance/comp_params_inheritance.err index 69489949359..b2abde26e73 100644 --- a/tests/semantic/comp_params_inheritance/comp_params_inheritance.err +++ b/tests/semantic/comp_params_inheritance/comp_params_inheritance.err @@ -1,4 +1,4 @@ -Error: Undefined relation impl.R in file comp_params_inheritance.dl at line 10 - Base(x) :- impl.R(x). ----------------^---------- +Error: Component T not found in file comp_params_inheritance.dl at line 8 + .init impl = T +-----------------^- 1 errors generated, evaluation aborted