Skip to content

Fix duplicate $td$ typedesc var for const type alias - #44653

Open
senuriwick wants to merge 1 commit into
ballerina-platform:2201.13.xfrom
senuriwick:bugfix/issue-44586
Open

Fix duplicate $td$ typedesc var for const type alias#44653
senuriwick wants to merge 1 commit into
ballerina-platform:2201.13.xfrom
senuriwick:bugfix/issue-44586

Conversation

@senuriwick

Copy link
Copy Markdown
Contributor

Purpose

Compiling a module containing a type definition that aliases directly to a constant fails with a generic, unhelpful error.

Fixes #44586

Approach

The fix tracks generated typedesc variable names per module in createTypedescVariable and skips creation if a variable with that name already exists, with the tracking reset per module (not per type-definition or per statement list, so as not to disturb the existing, narrower typedescList batching) deduping by generated name rather than by BType object identity, since the two colliding types are structurally related but not the same Java object.

Samples

import ballerina/io;

public const MAP = {
    "foo" : "bar"
};

public type Alias MAP;

public function main() {
    io:println("hello world");
}

Remarks

The current fix dedupes by generated name within a module. This mirrors an existing name-based guard in the same method, but in principle two distinct types could theoretically share a generated name (e.g. via import-shadowing of simple names). This wasn't observed as an issue and is considered out of scope for this fix; flagging for awareness.

Check List

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be081510-acee-4d4b-92f1-36f9b597f4fd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@senuriwick
senuriwick marked this pull request as ready for review July 10, 2026 03:54
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.

1 participant