Report a declared port whose name cannot be bound - #1216
Open
dv-picknik wants to merge 1 commit into
Open
dv-picknik wants to merge 1 commit into
dv-picknik wants to merge 1 commit into
Conversation
A SubTree model can declare a port that nothing is able to bind, and nothing
says so.
`validatePortName` rejects only a leading digit, so `<input_port
name="_myPort"/>` is accepted. `IsAllowedPortName` requires an alphabetic first
character, and `createNodeFromXML` uses it to classify every instance
attribute, so `_myPort="{outer}"` is diverted into `other_attributes`, the
remapping is dropped, and the SubTree reads its declared default:
Parent sets outer='FROM_PARENT'. Declared default is DEFAULT_NOT_WIRED.
myPort inside SubTree -> FROM_PARENT
_myPort inside SubTree -> DEFAULT_NOT_WIRED
`InputPort("_myPort")` already throws "Underscore is reserved", so the C++ API
and the XML declaration path disagree about the same name.
Throw when an instance attribute names a port the node declares but cannot
bind. Declared ports live in two places, so the check reads `manifest->ports`
for a registered node and `subtree_models` for a SubTree.
Rejecting the declaration in `validatePortName` would be the smaller change. It
would also break XML that loads today: a port declared and never remapped is
inert, and generated Objectives can carry such a declaration. This fires only
where a remapping is actually being lost, so an inert declaration keeps loading.
This branch has not been deployed
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.
Fixes #1215.
A SubTree model can declare a port that nothing is able to bind, and nothing says so.
validatePortNamerejects only a leading digit, so<input_port name="_myPort"/>is accepted.IsAllowedPortNamerequires an alphabetic first character, andcreateNodeFromXMLuses it to classify every instance attribute. So_myPort="{outer}"lands inother_attributes, the remapping is dropped, and the SubTree reads its declared default:InputPort("_myPort")already throws "Underscore is reserved", so the C++ API and the XML declaration path disagree about the same name.This throws when an instance attribute names a port the node declares but cannot bind. Declared ports live in two places, so the check reads
manifest->portsfor a registered node andsubtree_modelsfor a SubTree.Two ways to fix it
validatePortName, matchingIsAllowedPortName. One line, and it removes the inconsistency at its source. It also stops XML that loads today, since a declaration nobody remaps is inert and generated trees can carry one.This PR does 2, because it breaks nothing that works today. Say the word and I will switch it to 1.
Behavioral change
One case that loaded before now throws, and it is the case that was losing data. No API or ABI change.
_myPortdeclared and remapped on the instance_my_editor_stateon an instance that does not declare it_myPortdeclared and never remappedTesting
pixi run build && pixi run test, 533/533.SubTree.DeclaredPortNameThatCannotBeBoundfails on master and passes here. The other two pass either way, so a later tightening cannot break them unnoticed.pre-commit runclean, clang-format included.For clang-tidy I could not use
run_clang_tidy.shdirectly, since it wantscompile_commands.jsonunder the source tree, andclangd-21is not available on the machine I built on. I ran its clangd-21 invocation, flags and skip list unchanged, inside an Ubuntu 24.04 container built from the install steps in CONTRIBUTORS_GUIDE.md. Both changed files reportAll checks completed, 0 errors, and 114 of the 116 swept files undersrc/andinclude/are clean. The two that are not,bt_parser.handleaf_node.h, have nocompile_commands.jsonentry, so clangd analyzes them with no flags and cannot resolve their includes. That is unrelated to this change and reproduces on master.Co-authored by Claude Opus 5