Don't save curModule in module parser

The `module` parser was previously used for path parsing. It is
currently only used for parsing module prefixes of identityref leaf data
values. However, that is actually a mistake. Before the leaf_data parser
rework, there was a another module parser, that DIDN'T SAVE the
curModule (which is the point of this patch), but I accidently deleted
the wrong one and used this one, that saved the current module. This led
to a bug, where the identityref sets the current module, and then the
list called "inventory", in the new test, gets parsed as
"other:inventory".

Also, I'm gonna get rid of curModule, so one less usage of the variable
makes it easier.

Change-Id: I828750092c7fba71c1646e3aa6c190d9e07c58af
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 7d38d73..f378c18 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -116,9 +116,7 @@
         auto& parserContext = x3::get<parser_context_tag>(context);
         const auto& schema = parserContext.m_schema;
 
-        if (schema.isModule(ast.m_name)) {
-            parserContext.m_curModule = ast.m_name;
-        } else {
+        if (!schema.isModule(ast.m_name)) {
             parserContext.m_errorMsg = "Invalid module name.";
             _pass(context) = false;
         }
diff --git a/tests/list_manipulation.cpp b/tests/list_manipulation.cpp
index 974d806..d2ad5f9 100644
--- a/tests/list_manipulation.cpp
+++ b/tests/list_manipulation.cpp
@@ -7,6 +7,7 @@
 
 #include "trompeloeil_doctest.hpp"
 #include "parser.hpp"
+#include "pretty_printers.hpp"
 #include "static_schema.hpp"
 
 TEST_CASE("list manipulation")
@@ -14,10 +15,17 @@
     using namespace std::string_literals;
     auto schema = std::make_shared<StaticSchema>();
     schema->addModule("mod");
+    schema->addModule("other");
     schema->addList("/", "mod:list", {"number"});
     schema->addLeaf("/mod:list", "mod:number", yang::Int32{});
     schema->addLeaf("/mod:list", "mod:leafInList", yang::String{});
     schema->addLeafList("/", "mod:addresses", yang::String{});
+    schema->addIdentity(std::nullopt, identityRef_{"other", "deptypes"});
+    schema->addIdentity(identityRef_{"other", "deptypes"}, identityRef_{"other", "engineering"});
+    schema->addList("/", "mod:company", {"department"});
+    schema->addLeaf("/mod:company", "mod:department", schema->validIdentities("other", "deptypes"));
+    schema->addList("/mod:company", "mod:inventory", {"id"});
+    schema->addLeaf("/mod:company/mod:inventory", "mod:id", yang::Int32{});
     Parser parser(schema);
     std::string input;
     std::ostringstream errorStream;
@@ -33,6 +41,17 @@
             expectedPath.m_nodes.push_back(dataNode_{module_{"mod"}, listElement_("list", keys)});
         }
 
+        SECTION("mod:company[department=other:engineering]/inventory[id=1337]")
+        {
+            input = "mod:company[department=other:engineering]/inventory[id=1337]";
+            auto keys = std::map<std::string, leaf_data_>{
+                {"department", identityRef_{"other", "engineering"}}};
+            expectedPath.m_nodes.push_back(dataNode_{module_{"mod"}, listElement_("company", keys)});
+            keys = std::map<std::string, leaf_data_>{
+                {"id", int32_t{1337}}};
+            expectedPath.m_nodes.push_back(dataNode_{listElement_("inventory", keys)});
+        }
+
         SECTION("create mod:addresses['0.0.0.0']")
         {
             input = "mod:addresses['0.0.0.0']";
diff --git a/tests/pretty_printers.hpp b/tests/pretty_printers.hpp
index 7f59adc..429a0e9 100644
--- a/tests/pretty_printers.hpp
+++ b/tests/pretty_printers.hpp
@@ -122,6 +122,11 @@
     return s;
 }
 
+std::ostream& operator<<(std::ostream& s, const create_& create)
+{
+    s << "\nls_ {\n    " << create.m_path << "}\n";
+    return s;
+}
 
 std::ostream& operator<<(std::ostream& s, const ls_& ls)
 {