Skip to content

improve(core): upgrade trace macro and add custom assert messages - #1579

Open
sqrew wants to merge 1 commit into
carp-lang:masterfrom
sqrew:pr-improve-trace-and-assert
Open

improve(core): upgrade trace macro and add custom assert messages#1579
sqrew wants to merge 1 commit into
carp-lang:masterfrom
sqrew:pr-improve-trace-and-assert

Conversation

@sqrew

@sqrew sqrew commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Improves Debug.trace to display the expression text along with its value (using prn formatting), adds custom error message support to global assert via varargs, and removes the redundant/buggy Dynamic.Debug.trace macro.

;; This file verifies the improved 'trace' and 'assert' macros in core/Debug.carp

(defn main []
(let [x (Debug.trace (+ 10 20))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is the output from these trace calls checked somewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, you're probably right that it should be though. I didn't think of that!!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should be doable if you add it to the tests that check their output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @eriksvedang! I looked into adding the output check to the produces-output/ suite, but I ran into a bit of a snag with how trace resolves paths.

Because the macro uses (file) under the hood, it evaluates to the absolute path of the file at compile time. If I add it to produces-output, the .expected file would need my hardcoded local path (e.g., /home/.../Carp/test/...) and
would instantly fail on GitHub Actions when the CI runner checks it out to a different directory.

I could write a custom shell script to sanitize $PWD from the test output, but since the rest of the test suite cleanly uses execute.sh, I figured it's better to avoid polluting the test harnesses with one-off hacks. Because of this,
the test currently just executes the macro to ensure it compiles and evaluates properly without crashing. Let me know if you'd still prefer me to add a path-sanitizing hack to the test scripts though!

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.

3 participants