Repository navigation
Conversation
Extract subscript accesses as calls to a 'subscript' member, and subscript declarations as getter/setter 'subscript' methods marked with get/set modifiers. The setter clones the subscript parameters and takes the new value as an extra trailing positional parameter. Calls in assignment or in-place update positions now invoke setter methods, generalizing the existing property setter call logic. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the get/set modifiers on subscript methods with a distinct setter name, resolve setter calls by looking up 'name=' on the receiver, and let MaD models match setter calls via the 'name=' method name. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The subscript getter is a plain 'subscript' function declaration, and the setter an accessor_declaration of kind 'setter_method' with the same name. Accessor declarations gain a type_parameter field for generic subscripts. Setter calls resolve to the setter_method accessor with the callee's name; MaD models still refer to setter calls as 'name='. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
asgerf
force-pushed
the
asgerf-swift-subscript-support
branch
from
November 12, 2026 11:14
db727ed to
6e07e9e
Compare
asgerf
force-pushed
the
asgerf-swift-subscript-support
branch
from
November 12, 2026 19:38
6e07e9e to
82d058d
Compare
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.
Swift subscripts were not modelled.
xs[i]was extracted as a call toxsitself, andsubscriptdeclarations becameunsupported_node, so no data flowed through them.Representation
xs[i]is now a call to a member namedsubscript, i.e.xs.subscript(i).function_declarationnamedsubscriptfor the getter. If there is a setter, it is extracted as a separatefunction_declarationnamedsubscript=, placed next to the getter and taggedchained_declaration.newValue, or the name given inset(v). It has no return type.subscriptis ignored for now.Data flow
foo=is aSetterMethodDeclaration.resolveSetterCallTargetresolvesx.foo(...)tofoo=on the receiver type, for both instance and static members.x[i] = v,x[i] += v,x[i].f = von value types, and&x[i].c.s[0] = valso writes back throughs's setter.LegacyMaD
subscript(...)models already match getter calls, since matching is by member name plus argument labels.subscript=(...)models. The labels are the call's labels plus one extra_:for the value.Review notes
x[i] += v.... .subscriptcallee node.ql/test/library-tests/dataflow/subscripts.swiftand the extractor corpus (tests/corpus/swift/subscripts/).