schema compile BUGFIX compiled relics when recompiling context

types and extensions were not fully recompiled when the context is being
recompiled.
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 3e50e1e..5db58e0 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -52,6 +52,13 @@
 {
     LY_ERR ret = LY_SUCCESS;
 
+    if (ext_p->compiled && (ext_p->compiled->refcount == 1)) {
+        /* context recompilation - all the extension instances were previously freed (the last link to the compiled extension
+         * remains from the parsed extension definition) and now we are recompiling them again, to have the up-to-date
+         * extension definition, we have to recompile it as well now */
+        lysc_extension_free(ctx->ctx, &ext_p->compiled);
+    }
+
     if (!ext_p->compiled) {
         lysc_update_path(ctx, NULL, "{extension}");
         lysc_update_path(ctx, NULL, ext_p->name);