Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve debugging of Mint values. #704

Merged
merged 2 commits into from
Nov 17, 2024
Merged

Improve debugging of Mint values. #704

merged 2 commits into from
Nov 17, 2024

Conversation

gdotdesign
Copy link
Member

This PR improves how Mint values (types) are printed. Before this PR, when using Debug.log or dbg the JavaScript versions of values are being printed to the console:

image

Which is OK, but we can do better. This PR changes that to this:

image

Basically, we instrument the generated code, injecting the name of the records and variants so we can pretty print them.

If we are using dbg we have a location as well (this is not new):

image

Other things:

  • Added Debug.inspect which returns the pretty printed version.
  • Debug.log remains as-is printing the raw values.
  • dbg is now using the pretty printed version by default, to get the raw value we can use dbg!
  • The location line is not printed if source maps are enabled because it's redundant since it will point to the source.
    image

Resolves #641.

@gdotdesign gdotdesign added the enhancement New feature or request label Nov 16, 2024
@gdotdesign gdotdesign added this to the 0.21.0 milestone Nov 16, 2024
@gdotdesign gdotdesign requested a review from Sija November 16, 2024 08:34
@gdotdesign gdotdesign self-assigned this Nov 16, 2024
runtime/src/debug.js Show resolved Hide resolved
src/compilers/dbg.cr Show resolved Hide resolved
src/compilers/dbg.cr Show resolved Hide resolved
@gdotdesign gdotdesign merged commit 942c4b6 into master Nov 17, 2024
3 checks passed
@gdotdesign gdotdesign deleted the debug-improvements branch November 17, 2024 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

Improve debug information for complex types
2 participants