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

Verify functions have sized parameters/return values #2738

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

powerboat9
Copy link
Contributor

This adds an extra compiler pass called SizedChecker which handles the new checks

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

this is a great idea, thank you :) I like how simple it is too

@@ -254,6 +254,7 @@ struct CompileOptions
NameResolution,
Lowering,
TypeCheck,
SizedCheck,
Copy link
Member

Choose a reason for hiding this comment

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

you'll need to update gcc/rust/lang.opt as well to add that option


for (auto &param : fntype->get_params ())
if (!is_sized (param.second))
rust_error_at (param.first->get_locus (), "function parameter type %<%s%> is dynamically sized", param.second->as_string ().c_str ());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rust_error_at (param.first->get_locus (), "function parameter type %<%s%> is dynamically sized", param.second->as_string ().c_str ());
rust_error_at (param.first->get_locus (), "function parameter type %qs is dynamically sized", param.second->as_string ().c_str ());

TyTy::BaseType *ret_type = fntype->get_return_type ();
if (!is_sized (ret_type))
// TODO: give this a better location_t
rust_error_at (function.get_locus (), "function return type %<%s%> is dynamically sized", ret_type->as_string ().c_str ());
Copy link
Member

Choose a reason for hiding this comment

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

same here

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.

2 participants