Fix attributes silently dropped on unparenthesized tuple return types#19714
Open
edgarfgp wants to merge 5 commits into
Open
Fix attributes silently dropped on unparenthesized tuple return types#19714edgarfgp wants to merge 5 commits into
edgarfgp wants to merge 5 commits into
Conversation
…dotnet#462) In `pars.fsy`, the `topType → topTupleType` rule discarded all `SynArgInfo` entries via `SynInfo.unnamedRetVal` whenever the return type was a bare multi-element tuple (e.g. `string * string`). Attributes placed before the tuple were parsed into the first element's `SynArgInfo` but then silently dropped, never reaching `SynBindingReturnInfo` or IL emission. The fix promotes attributes from the first element's `SynArgInfo` to the overall return `SynArgInfo` when they are non-empty, so that: static member Foo() : [<ReturnDescription("...")>] string * string = ... now correctly emits the attribute to `.param [0]` in IL, matching the behaviour of the parenthesized form `(string * string)`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These were side effects of running TEST_UPDATE_BSL=1 and are unrelated to the fix for dotnet#462.
Contributor
❗ Release notes required
|
auduchinok
reviewed
May 11, 2026
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 #462
Problem
When a method return type is an unparenthesized tuple, any attributes placed before it are silently dropped and never emitted to IL:
Root cause
In
pars.fsy, thetopType → topTupleTypegrammar rule handles the return type annotation. When the return type is a bare multi-element tuple,rmdata(the list ofSynArgInfoper tuple element) has more than one entry, so the rule fell into a catch-all branch that replaced everything withSynInfo.unnamedRetVal— an emptySynArgInfowith no attributes:The attributes were parsed correctly into the first element's
SynArgInfobut then discarded here, never reachingSynBindingReturnInfoor IL emission.Fix
Promote attributes from the first element's
SynArgInfoto the overall returnSynArgInfowhen they are non-empty, since attributes placed before the whole tuple belong to the return position:Tests
ReturnType04.fs— runtime reflection test asserting attributes appear on the return parameter for both parenthesized and bare tuple formsAttribute/ReturnTypeAttributeOnBareTuple.fs+.bsl— SyntaxTree parser test documenting thatSynValInfonow carries the correctSynArgInfowith attributes in the return position for bare tuples