Skip to content

test: cover printable typeof on sumtypes#26770

Merged
JalonSolov merged 7 commits into
vlang:masterfrom
vincenzopalazzo:codex/fix-26704-typeof-printable
Mar 30, 2026
Merged

test: cover printable typeof on sumtypes#26770
JalonSolov merged 7 commits into
vlang:masterfrom
vincenzopalazzo:codex/fix-26704-typeof-printable

Conversation

@vincenzopalazzo

Copy link
Copy Markdown
Contributor

Summary

Root cause

The original issue was a codegen regression in older compiler builds when println(typeof(step)) was used on a sumtype. The current tree no longer reproduces that failure, but there was no targeted test covering that path.

Verification

  • ./vnew -gc none -silent vlib/v/tests/typeof_test.v
  • ./vnew -g -o /tmp/issue26704_pr.c /tmp/issue26704_pr.v
  • ./vnew -gc none /tmp/issue26704_pr.v && /tmp/issue26704_pr

Fixes #26704

@JalonSolov

Copy link
Copy Markdown
Collaborator

Close/re-open for CI run.

@JalonSolov JalonSolov closed this Mar 30, 2026
@JalonSolov JalonSolov reopened this Mar 30, 2026
@JalonSolov

Copy link
Copy Markdown
Collaborator

A conflict to resolve, and a problem with typeof to be fixed (shows in the diff view).

Copy link
Copy Markdown
Contributor Author

Fixed in dbeba19. The PR diff is back to vlib/v/tests/typeof_test.v only, and the regression now exercises println(typeof(...)) directly while asserting the raw typeof values without the helper.

Verified with ./vnew -gc none -silent vlib/v/tests/typeof_test.v.

@JalonSolov

Copy link
Copy Markdown
Collaborator

Still failing CI with:

Error: vlib/v/tests/typeof_test.v:132:10: error: use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead

The compiler rejects bare typeof(expr) as a printable expression,
requiring typeof(expr).name instead. Use the already-assigned
intermediate variables to print the typeof results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vincenzopalazzo

Copy link
Copy Markdown
Contributor Author

Trying with 7e62c50

@JalonSolov JalonSolov merged commit d599d81 into vlang:master Mar 30, 2026
84 of 85 checks passed
medvednikov pushed a commit that referenced this pull request Apr 4, 2026
* test: cover printable typeof on sumtypes

Fixes #26704

* fix: avoid v2 verbose timing gotos

* fix: harden v2 staged C replacement

* test: cover inline printable typeof on sumtypes

* fix: address PR review feedback

* fix: use stored typeof result in println to avoid compiler error

The compiler rejects bare typeof(expr) as a printable expression,
requiring typeof(expr).name instead. Use the already-assigned
intermediate variables to print the typeof results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Printing typeof() fails to compile

2 participants