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

Add typechecking to model signatures #867

Merged

Conversation

Michael-F-Bryan
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan commented Jul 23, 2022

This fixes #849 by placing the original model function inside our generated extern "C" fn model(), letting the Rust compiler make sure it type checks. From there, it's simple to call the original function with its parsed arguments and assert that the result is convertible to a fj::Shape.

I've also added some examples to the attribute's docs so we can make sure #[model] fn model() { todo!() } doesn't compile.

Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

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

Thank you, @Michael-F-Bryan, looks great!

@hannobraun hannobraun merged commit d2a7c0b into hannobraun:main Jul 24, 2022
@Michael-F-Bryan Michael-F-Bryan deleted the typecheck-model-signatures branch July 25, 2022 02:19
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.

#[fj::model] should check signature of model function
2 participants