🐛 Fix Argument Parameters with Dynaports #458
Merged
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.
Description
This PR fixes a
TypeError: 'InArg' object is not subscriptableerror that occurred when using dynamic ports (dynalist/dynatuple) with indexed connections to Argument parameters in Xircuits workflows.Previously, when the compiler generated code for dynamic ports connected to Argument parameters at specific indices, it would fail because
InArgobjects didn't support subscript operations. When users tried to connect Argument parameters to specific indices of dynamic ports (e.g.,dlist[1].connect(self.test2)), the generated code would throw aTypeError: 'InArg' object is not subscriptable.This PR implements two changes:
Added subscript support to InArg class (base.py): Implemented getitem and setitem methods with an _IndexProxy helper class to enable indexed access and connection syntax like port[i].connect(other_port).
Updated code generation for dynamic ports (generator.py): Changed from bulk assignment to per-element indexed operations that generate proper code for Argument parameters (.connect()), component references (.connect()), and literal values (direct assignment).
So previously given a workflow like this:
The incorrect generated code would look like:
Error Code:
With the new this PR:
Output:
References
Fixes the TypeError when Argument parameters are connected to indexed positions in dynamic ports (dynalist/dynatuple).
Pull Request Type
Type of Change
Tests
1. Dynamic Port with Argument Parameter Test
Tested on? Specify Version.