|
|
@@ -268,6 +268,16 @@ private:
|
|
|
detail::Reference lexical = context.ref.canonicalize(ref, context.where, dynamic_reference);
|
|
|
detail::Reference dynamic = dynamic_reference ? lexical : context.dynamic_where / "$ref";
|
|
|
|
|
|
+ detail::OnBlockExit scope;
|
|
|
+ if (lexical.uri() != context.where.uri()) {
|
|
|
+ // Whenever we change base URIs, we need to recalculate our dynamic_scope.
|
|
|
+ // Otherwise, it is possible for a chain of $ref statements to
|
|
|
+ // accidentally leave us ignoring $dynamicAnchor contexts.
|
|
|
+ // This is demonstrated by the test descriptor in JSON-Schema-Test-Suite:
|
|
|
+ // "$dynamicRef avoids the root of each schema, but scopes are still registered"
|
|
|
+ scope = context.ref.dynamic_scope(lexical);
|
|
|
+ }
|
|
|
+
|
|
|
if (std::optional cached = from_cache(dynamic)) {
|
|
|
return *cached;
|
|
|
}
|