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

chore(compiler): Add warning for print and toString with unsafe values #2018

Merged
merged 7 commits into from Mar 3, 2024

Conversation

spotandjake
Copy link
Member

@spotandjake spotandjake commented Feb 13, 2024

This adds a warning when we detect a user trying to print an unsafe wasm value. This is similar to how we warn about == and != on unsafe types.

I question if we should actually warn about this or just error as code such as print(0.0W) results in bad wasm generation which creates a nasty compiler error.

Counter Idea to improve dev experience

A counter-proposal to this pr, which might require some more complexity is we allow you to print unsafe types and just replace the call to Pervasives.print when we recognize it with the coresponding DebugPrint call. I think this would improve the developer experience when working with unsafe types and speed up development using them.

Future Safety Warning

We might also want to open an issue to block the usage of unsafe types on variables that cannot be inferred to prevent bad code generation.

Would love to hear people's thoughts on this.

compiler/src/utils/warnings.re Outdated Show resolved Hide resolved
compiler/src/utils/warnings.re Outdated Show resolved Hide resolved
@spotandjake spotandjake force-pushed the spotandjake-unsafe-print-warn branch from cf13398 to 4177e5b Compare March 3, 2024 01:22
@phated phated requested a review from ospencer March 3, 2024 01:56
@phated phated changed the title chore(compiler): Add warning for unsafe print chore(compiler): Add warning for print and toString with unsafe values Mar 3, 2024
Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

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

LGTM. Waiting for @ospencer to review

@ospencer ospencer added this pull request to the merge queue Mar 3, 2024
Merged via the queue into grain-lang:main with commit e64f2ff Mar 3, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants