-
Notifications
You must be signed in to change notification settings - Fork 180
lib.wiring.connect: diagnostic when no connection made. #1153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib.wiring.connect: diagnostic when no connection made. #1153
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1153 +/- ##
==========================================
+ Coverage 85.88% 85.89% +0.01%
==========================================
Files 43 43
Lines 8679 8687 +8
Branches 2065 2067 +2
==========================================
+ Hits 7454 7462 +8
- Misses 1024 1025 +1
+ Partials 201 200 -1 ☔ View full report in Codecov by Sentry. |
Thanks for bringing this to our attention. I don't actually recall what happened there; I think this is a simple case of a miscommunication between the spec author and the implementer (made somewhat more awkward by the fact that both of those are, theoretically, me.) I cannot provide a justification for allowing
Enabling such type-guided programming is an explicit goal, and the current situation does create a hazard. Adding a diagnostic here is clearly appropriate; I find it unlikely that anyone will strongly desire to have a The larger question is whether to forbid |
Thinking about it more, I think a part of the motivation at least was the case of So to break down the possible cases here:
I think we should (if we do not already) have tests for cases 1-4, and I think turning case 3 into a hard error (while leaving cases 1 and 2 alone) without a deprecation cycle is clearly justified. I think there's no clear justification for doing anything about case 4 but I'm happy to reconsider if others justify why it should or shouldn't be allowed. |
Relatable!
Yep, agreed, and I'm a fan of using "stands out well in source code" as a point of reference when determining how likely things are to be a mistake/source of surprising danger.
Scanned briefly, appears; 1: not yet; 2: not yet; 3: only the one added here; 4: not yet. Will add {1,2,4} and some commentary. |
If a connect() call results in no connections being made, and it's because there were no outputs specified at all, issue an error. Tests enumerate cases per #1153 (comment). Co-authored-by: Catherine <whitequark@whitequark.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Commit message:
(I've read the RFCs and git logs reasonably carefully but I'm basically assuming I've missed something/a decision made since. Apologies if so!)
RFC 2 § Interface connection states
lib.wiring.connect
's requirements:The actual implementation diverges; the docstring listing these requirements omits the last point, and notes later on:
I can appreciate this probably comes in handy when connecting larger/nested signatures, but while orienting my head around "which way is
In
/ which way isOut
" and taking advantage of the newMemory
's port signatures, I ended up lost for a while wondering why nothing was propagating when I was connecting aWritePort
to a submodule.tl;dr I annotated the destination member as
Out(WritePort.Signature(…))
, since it had anotherOut(…)
next to it and I was on autopilot while adding it. Write ports consist entirely ofIn
members, meaningconnect(m, mem.write_port(), thing.write_port)
in such circumstances will quietly do nothing.(Read ports do issue errors under such circumstances, since they have one
Out
member which will then clash. I was doing type-guided programming (aka "just keep adding/removingflipped
on various members until it doesn't throw an error") y'know.)I've added a diagnostic here which raises if we never encounter a path with a corresponding output port member. Having a constant output (with its matching input) is sufficient.
I don't have visibility on larger designs so I'm not sure if this is going too far; no sweat if it's inappropriate.