Skip to content

Go: support generics#4397

Open
masatake wants to merge 4 commits intouniversal-ctags:masterfrom
masatake:go--generics
Open

Go: support generics#4397
masatake wants to merge 4 commits intouniversal-ctags:masterfrom
masatake:go--generics

Conversation

@masatake
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial Go generics (type parameters) support to the Go parser, including new tag kind/fields and a corresponding unit test fixture.

Changes:

  • Introduce a tparam kind and tparams field for Go func tags.
  • Parse and attach type-parameter lists for generic functions/methods.
  • Add a generics-focused unit test and update docs/news and field listing expectations.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
parsers/go.c Adds parsing and tagging for Go generic type parameters and exposes them via a new field/kind.
docs/news/HEAD.rst Documents the new Go receiver/tparams tagging support.
Units/parser-go.r/go-generics.d/input.go New test input covering a generic function with type constraints.
Units/parser-go.r/go-generics.d/expected.tags Expected tags updated to assert tparam and tparams output.
Units/parser-go.r/go-generics.d/args.ctags Test args enabling the new Go kind/field.
Tmain/list-fields.d/stdout-expected.txt Updates field-list output to include tparams.
Tmain/list-fields-with-prefix.d/stdout-expected.txt Updates prefixed field-list output to include tparams.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@27c0c41). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4397   +/-   ##
=========================================
  Coverage          ?   86.07%           
=========================================
  Files             ?      254           
  Lines             ?    63905           
  Branches          ?        0           
=========================================
  Hits              ?    55005           
  Misses            ?     8900           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{true, 'P', "packageName", "name for specifying imported package"},
{true, 'a', "talias", "type aliases"},
{false,'R', "receiver", "receivers"},
{false,'Z', "tparam", "type parameters", .version = 1, },
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initializer for the new tparam kind includes an extra trailing comma before the closing brace (.version = 1, }). While accepted by many compilers, it can trigger warnings under stricter compilation settings; consider removing it to match the style of neighboring initializers.

Suggested change
{false,'Z', "tparam", "type parameters", .version = 1, },
{false,'Z', "tparam", "type parameters", .version = 1 },

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this style because this style makes a patch I will create in the future smaller.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@masatake masatake force-pushed the go--generics branch 2 times, most recently from 7ec1e29 to 4fc6a2a Compare March 12, 2026 17:02
@masatake masatake requested a review from Copilot March 12, 2026 17:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 21 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

parsers/go.c:1411

  • In parseConstTypeVar, kind is mutated to GOTAG_TALIAS when = is encountered. Because kind is then reused for subsequent TypeSpecs in the same type (...) declaration, any later non-alias type specs can be mis-parsed/tagged as talias (and may skip the type-body parsing path guarded by kind == GOTAG_TYPE). Use a per-spec variable (e.g., specKind) instead of modifying the function parameter.
					if (isType (token, TOKEN_EQUAL))
					{
						kind = GOTAG_TALIAS;
						readToken (token);
					}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@masatake masatake changed the title Go: start supporting generic features Go: support generics Mar 13, 2026
@masatake masatake requested a review from Copilot March 13, 2026 15:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@masatake masatake force-pushed the go--generics branch 2 times, most recently from a74df58 to 4ee8b08 Compare March 13, 2026 16:56
@masatake masatake requested a review from Copilot March 13, 2026 16:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +859 to +886
static bool isArraySpec (intArray *corks, vString *tparams_str)
{
const char *cstr = vStringValue (tparams_str);
size_t cstr_len = vStringLength (tparams_str);

if (intArrayCount (corks) == 0)
return true;

if (intArrayCount (corks) > 1 ||
(cstr_len > 2
&& cstr
&& cstr [cstr_len - 1] == ']'
&& cstr [cstr_len - 2] == ','))
return false;

for (unsigned int i = 0; i < intArrayCount (corks); i++)
{
int cork = intArrayItem (corks, i);
tagEntryInfo *e = getEntryInCorkQueue (cork);
if (!e)
return false; /* Maybe "_" in the array. */

if (e->extensionFields.typeRef [0])
return false; /* a constraint is given */
}

return true;
}
Comment on lines +964 to +969
if (isArraySpec (tparams_indexes, tparams->str))
{
markCorkEntryAsPlaceholderInBatch (tparams_indexes);
intArrayDelete (tparams_indexes);
tparams_indexes = NULL;
}
const (
UUIDBuflen = 256
)
type UUID [UUIDBuflen]byte
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@masatake masatake mentioned this pull request Mar 21, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants