From cd6201ca5c57fe6c6ab31e423cdb4afbbcfa383c Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Fri, 19 Jun 2026 22:42:02 +0200 Subject: [PATCH] fix(schema): make the container-location root fallback live containerLocationMap stored `loc ?? rootLocation` into a [ObjectIdentifier: String?]. Because the value type is itself optional the coalescing bound at the outer optional and rootLocation was never used (the compiler flagged it), so a container with no location of its own (the compile root) mapped to nil even when a circular import had loaded the root under a schemaLocation. An explicit String? annotation keeps the coalescing at the String level so the root inherits rootLocation. Conformance is unchanged: 1448 unit tests pass and the full XSTS suite still settles at 0/43/0/31. The SchemaNameUniqueness root-index dedup case is kept, not removed: an experiment removing it on the theory it was now redundant regressed three valid schemas to rejected, so it does real work beyond the fixed fallback. --- CHANGELOG.md | 11 +++++++++++ Sources/Schema/XSDParser.swift | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ebcbfd..541215a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed a dead `rootLocation` fallback in `XSDParser.containerLocationMap`. The + map value type is itself `String?`, so `loc ?? rootLocation` bound the + coalescing at the outer optional and never used `rootLocation` (the compiler + flagged it), leaving the compile root mapped to nil even when a circular import + had loaded it under a `schemaLocation`. An explicit `String?` annotation keeps + the coalescing at the `String` level so the root inherits its location. + Conformance is unchanged (XSTS still settles at 0/43/0/31); the + `SchemaNameUniqueness` root-index dedup case is retained, not removed, because + removing it on the theory it was now redundant regressed three valid schemas to + rejected, so it does real work beyond the fixed fallback. + - Bounded the content-model matcher's active-configuration set per counter (`ContentNFA`/`ContentMatcher`). Each occurrence counter now saturates at `min(maximum, inputLength + 1)`, and an unbounded counter at its `minimum` diff --git a/Sources/Schema/XSDParser.swift b/Sources/Schema/XSDParser.swift index 7b0ba46..1d2776a 100644 --- a/Sources/Schema/XSDParser.swift +++ b/Sources/Schema/XSDParser.swift @@ -64,7 +64,11 @@ extension PureXML.Schema.XSDParser { ) -> [ObjectIdentifier: String?] { var containerLocations: [ObjectIdentifier: String?] = [:] for (loc, tree) in containerTuples { - containerLocations[ObjectIdentifier(tree)] = loc ?? rootLocation + // The map value is itself `String?`, so the explicit annotation keeps + // `??` at the `String` level; without it the fallback binds at the + // outer optional and the compile root (no location) maps to nil. + let location: String? = loc ?? rootLocation + containerLocations[ObjectIdentifier(tree)] = location } return containerLocations }