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
ospencer
merged 7 commits into
grain-lang:main
from
spotandjake:spotandjake-unsafe-print-warn
Mar 3, 2024
Merged
chore(compiler): Add warning for print
and toString
with unsafe values
#2018
ospencer
merged 7 commits into
grain-lang:main
from
spotandjake:spotandjake-unsafe-print-warn
Mar 3, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spotandjake
requested review from
phated,
ospencer,
marcusroberts,
peblair and
jozanza
as code owners
February 13, 2024 12:02
ospencer
reviewed
Feb 21, 2024
spotandjake
force-pushed
the
spotandjake-unsafe-print-warn
branch
from
February 27, 2024 22:16
6fdc4ac
to
8fee35a
Compare
spotandjake
force-pushed
the
spotandjake-unsafe-print-warn
branch
from
March 3, 2024 01:22
cf13398
to
4177e5b
Compare
phated
changed the title
chore(compiler): Add warning for unsafe
chore(compiler): Add warning for Mar 3, 2024
print
print
and toString
with unsafe values
ospencer
reviewed
Mar 3, 2024
phated
requested changes
Mar 3, 2024
phated
approved these changes
Mar 3, 2024
There was a problem hiding this 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
approved these changes
Mar 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toPervasives.print
when we recognize it with the corespondingDebugPrint
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.