schema compile UPDATE internal module another rev implement

Allow implementing older 'yang' module revision
in case a newer one is in the context since the
changes in this module are always backwards-compatible.
diff --git a/src/schema_compile.c b/src/schema_compile.c
index f84d687..869eea8 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -1911,15 +1911,19 @@
 
     assert(!mod->implemented);
 
-    /* we have module from the current context */
+    /* check collision with other implemented revision */
     m = ly_ctx_get_module_implemented(mod->ctx, mod->name);
     if (m) {
         assert(m != mod);
-
-        /* check collision with other implemented revision */
-        LOGERR(mod->ctx, LY_EDENIED, "Module \"%s%s%s\" is present in the context in other implemented revision (%s).",
-                mod->name, mod->revision ? "@" : "", mod->revision ? mod->revision : "", m->revision ? m->revision : "none");
-        return LY_EDENIED;
+        if (!strcmp(mod->name, "yang") && (strcmp(m->revision, mod->revision) > 0)) {
+            /* special case for newer internal module, continue */
+            LOGVRB("Internal module \"%s@%s\" is already implemented in revision \"%s\", using it instead.",
+                    mod->name, mod->revision ? mod->revision : "<none>", m->revision ? m->revision : "<none>");
+        } else {
+            LOGERR(mod->ctx, LY_EDENIED, "Module \"%s@%s\" is already implemented in revision \"%s\".",
+                    mod->name, mod->revision ? mod->revision : "<none>", m->revision ? m->revision : "<none>");
+            return LY_EDENIED;
+        }
     }
 
     /* set features */
diff --git a/tests/utests/basic/test_context.c b/tests/utests/basic/test_context.c
index dddd0f3..7899079 100644
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -475,7 +475,7 @@
     /* invalid attempts - implementing module of the same name and inserting the same module */
     assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in2, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod2));
     assert_int_equal(LY_EDENIED, lys_implement(mod2, NULL, &unres));
-    CHECK_LOG_CTX("Module \"a@2018-10-24\" is present in the context in other implemented revision (2018-10-23).", NULL);
+    CHECK_LOG_CTX("Module \"a@2018-10-24\" is already implemented in revision \"2018-10-23\".", NULL);
     lys_unres_glob_erase(&unres);
     ly_in_reset(in1);
     /* it is already there, fine */