Throw an exception for duplicate interface port names - #694
Merged
mkorbel1 merged 1 commit intoAug 6, 2026
Conversation
`Interface._setPort` guarded against a port name colliding with one already on the interface using an `assert`, so the check was stripped in release mode and the second port silently replaced the first in `_ports`. Replace it with a `DuplicatePortNameException`, a new `RohdException` alongside the existing interface name and type exceptions, so the collision is reported in every build mode. Fixes intel#514
mkorbel1
approved these changes
Aug 6, 2026
mkorbel1
left a comment
Contributor
There was a problem hiding this comment.
Looks great, thank you for the contribution!
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 #514.
Interface._setPortcaught a port name that already exists on the interface with anassert:Asserts are stripped in release mode, so outside of tests the duplicate silently replaced the earlier entry in
_portsand the interface ended up carrying a port the caller never intended.This replaces it with a
DuplicatePortNameException, a newRohdExceptionalongside the existingInterfaceNameExceptionandInterfaceTypeExceptioninlib/src/exceptions/interface/, so the collision is reported in every build mode.Testing
New test in
interface_test.dartbuilds an interface that declares the same port name twice and expects the exception. Confirmed it fails against unmodifiedinterface.dartfirst — it threw_AssertionErrorrather than aRohdException— so the test genuinely covers the change.Full gate locally:
dart test1320 passed,dart format0 changed,dart analyze --fatal-infosclean,dart doc0 warnings and 0 errors,pana160/160.Note
This is a behavior change for release-mode builds that were unknowingly relying on the silent overwrite — that is the point of the issue, but flagging it since it could surface in downstream code. Happy to rename the exception or reword the message if you would prefer something different.