Repository navigation
fix: refuse a base container left concrete beside its own children - #4
Merged
Merged
Conversation
`abstract` defaults to false in XTCE, so a base SequenceContainer that nobody
marked — the ordinary CCSDS primary-header shape — is emitted as a concrete
container. Its generated `matches` is `true` for any buffer long enough to hold
it, and the module-level `decode` counts how many containers match. So every
packet matched the base and its own child, and `decode` answered `Ambiguous`
for all of them: a generated decoder that rejects every packet, from a
definition that generated without a word.
Refused at generation time now, naming the container and saying both ways out:
error: cannot compile <SequenceContainer> in FlightPacket: this container
has no restriction criteria, so it matches every packet long enough to hold
it; beside the other containers generated here that makes every packet
ambiguous. Mark it abstract="true" if other containers inherit from it, or
give it criteria that select it
Only when there is more than one container: a lone concrete container with no
criteria is the whole definition and decodes fine.
Found by a review sweep and reproduced with the bundled definition, by removing
one attribute from it. 43 tests, fmt and clippy clean.
`if a && let Some(b) = c` is unstable there, and a toolchain of 1.99 compiles it without a word. Checked against `cargo +1.85` this time rather than against the one that happens to be installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
abstractdefaults to false in XTCE, so a baseSequenceContainerthat nobody marked —the ordinary CCSDS primary-header shape, which is most definitions — is emitted as a concrete
container. Its generated
matchesistruefor any buffer long enough to hold it, and themodule-level
decodecounts how many containers match:So every packet matched the base and its own child, and
decodeansweredAmbiguousforall of them. A generated decoder that rejects every packet, from a definition that generated
without a word of complaint — and the place you would find out is the spacecraft.
Refused at generation time now, naming the container and giving both ways out:
Narrow on purpose: only when there is more than one container. A lone concrete container with
no criteria is the whole definition and decodes fine, so it still generates.
Reproduced against the bundled definition by removing one attribute from it;
flight_shapes.xmlitself still generates its two structs. 43 tests, fmt and clippy clean.