Skip to content

Annotate to_inspect in EncodeDecode and CustomInspect so newer nightlies still use it - #296

Merged
Anton-4 merged 1 commit into
roc-lang:mainfrom
showell:annotate-to-inspect
Sep 28, 2026
Merged

Anton-4 merged 1 commit into
roc-lang:mainfrom
showell:annotate-to-inspect

Conversation

@showell

@showell showell commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Since nightly-2026-09-23-c7852fd, a to_inspect method overrides inspection only when its type is T -> Str (roc-lang/roc#11573, landed via #11588; see "Inspect Overrides" in design.md).

Two examples declare to_inspect without an annotation and return a string literal. The unannotated result is polymorphic, because the literal could be any type with from_interpolation. So on newer nightlies both methods are silently ignored:

  • EncodeDecode prints Text, Method, … rather than the ItemKind.(Text), ItemKind.(Method), … its README and ci_scripts/expect_scripts/EncodeDecode.exp expect.
  • CustomInspect: Str.inspect(CreditCard.("1111 2222 3333 1234")) gives <opaque> instead of **** **** **** 1234, so the snippet's own expect fails under roc test. (CreditCard is opaque, so the number itself stays hidden here. The same override on a := nominal would print the number.)

This PR adds to_inspect : ItemKind -> Str and to_inspect : CreditCard -> Str. Checked with roc and roc test on nightly-2026-09-19-d025939 (the current pin), where the output is unchanged, and on nightly-2026-09-27-a3ce7f1, where both examples print what their READMEs say again and all their tests pass.

(09-27 also warns about the redundant .. in output-position tag unions in several examples. This PR doesn't touch those.)


Reported by Claude (Anthropic's Claude Code), working with @showell

🤖 Generated with Claude Code

Since nightly-2026-09-23, to_inspect overrides inspection only when its type
is T -> Str. Unannotated, a to_inspect that returns a string literal infers a
polymorphic result (the literal could be any type with from_interpolation), so
it is silently ignored.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
showell added a commit to showell/rocflight that referenced this pull request Sep 28, 2026
Since nightly-2026-09-23, to_inspect overrides inspection only when its
type is T -> Str. Unannotated, a to_inspect that returns a string literal
infers a polymorphic result, so roc 09-27 ignores EncodeDecode's and
CustomInspect's overrides. check_examples is 19/0 under 09-27 with our PRs.

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

Anton-4 commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

I also discovered this in #297. My PR has all the fixes combined so I will close this one. Thanks for the effort though!

@Anton-4
Anton-4 merged commit a7c1d6e into roc-lang:main Sep 28, 2026
3 of 4 checks passed
@Anton-4

Anton-4 commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

My PR has all the fixes combined so I will close this one.

I accidentally merged it, I was a bit sleep deprived 😅

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