Skip to content

fix: add hints for Num.to_str and Inspect.to_str errors#9283

Open
Sim-hu wants to merge 1 commit intoroc-lang:mainfrom
Sim-hu:fix/improve-qualified-ident-error-hints
Open

fix: add hints for Num.to_str and Inspect.to_str errors#9283
Sim-hu wants to merge 1 commit intoroc-lang:mainfrom
Sim-hu:fix/improve-qualified-ident-error-hints

Conversation

@Sim-hu
Copy link
Copy Markdown

@Sim-hu Sim-hu commented Mar 22, 2026

Closes #9192
Closes #9191

When a user writes Num.to_str(value) or Inspect.to_str(value), the current error just says the identifier doesn't exist. This adds a hint after the error pointing them to the right syntax:

Num.to_str: suggests method syntax value.to_str()

Inspect.to_str: suggests the renamed function Str.inspect

Follows the existing hint pattern used elsewhere in ModuleEnv.zig (e.g. addAnnotated("Hint:", .emphasized)).

Copy link
Copy Markdown
Collaborator

@lukewilliamboswell lukewilliamboswell left a comment

Choose a reason for hiding this comment

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

❤️

When a user writes Num.to_str or Inspect.to_str, the error message
now includes a hint suggesting the correct syntax:

- Num.to_str(value) -> value.to_str() (method syntax)
- Inspect.to_str -> Str.inspect (renamed)

Closes roc-lang#9192
Closes roc-lang#9191
auto-merge was automatically disabled March 22, 2026 10:09

Head branch was pushed to by a user without write access

@Sim-hu Sim-hu force-pushed the fix/improve-qualified-ident-error-hints branch from 7d22c4b to 52f7547 Compare March 22, 2026 10:09
@lukewilliamboswell
Copy link
Copy Markdown
Collaborator

lukewilliamboswell commented Mar 22, 2026

Did you mean to drop my commits?

I'm not sure why CI failed in that last run, it looks like just the cross-compile runners -- but it's not clear what the issue was. It doesn't look to me like it's related to this change, but there must be something I guess. I'll kick off CI so we can try again without the tests I added.

@Sim-hu
Copy link
Copy Markdown
Author

Sim-hu commented Mar 22, 2026

Sorry about that — I rebased to pick up recent fixes and force-pushed without checking if you'd added commits. Won't happen again.

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.

Num.to_str better error message Inspect.to_str better error

2 participants