Skip to content

compiler: keep class field and method types that match the name - #2952

Open
fguinez wants to merge 5 commits into
d2lang:masterfrom
fguinez:fix/class-field-type-matches-name
Open

fguinez wants to merge 5 commits into
d2lang:masterfrom
fguinez:fix/class-field-type-matches-name

Conversation

@fguinez

@fguinez fguinez commented Oct 23, 2026 •

Copy link
Copy Markdown

Fixes #2951

Stacked on #2950: the first two commits belong to it, the rest are this PR's.

date: date in a shape: class rendered the field with an empty type, and
now(): now() rendered the method returning void. compileClass had the
same check #2950 changes for sql_table columns.

The first commit moves the explicit label lookup from #2950 into a
hasExplicitLabel helper. The second uses it in compileClass. Fields and
methods without a label still render with no type and void.

A column's label defaults to its name, so compileSQLTable blanked the
type whenever the two matched, including when the label was set
explicitly (date: date). Record explicit labels and only blank the type
when there is none.

Fixes d2lang#1960
A class field or method label defaults to its name, so compileClass
dropped the field type, or replaced the return type with void, whenever
the two matched, including when the label was set explicitly
(date: date). Only fall back when there is no explicit label.

Fixes d2lang#2951
Copilot AI lite review requested due to automatic review settings October 23, 2026 03:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

compiler: class field and method types are dropped when they match the name

2 participants