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

Validate return types of all behavior callbacks #1169

Open
zachdaniel opened this issue May 15, 2024 · 0 comments
Open

Validate return types of all behavior callbacks #1169

zachdaniel opened this issue May 15, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zachdaniel
Copy link
Contributor

zachdaniel commented May 15, 2024

The steps for this:

For all callbacks on behaviour modules, we should switch from calling module.callback to calling Behaviour.callback(module, ...). These wrapper functions will do two things:

  1. they will have type specs that allow for dialyzer to know what these functions return
  2. they will match on the return types, and if they don't return a valid return value, they will instead raise an Ash.Error.Framework.InvalidReturnType explaining the bad return type.

This will make dialyzer more helpful throughout the project and also help users when they accidentally return the wrong value from a callback function.

@zachdaniel zachdaniel added enhancement New feature or request good first issue Good for newcomers labels May 16, 2024
@zachdaniel zachdaniel changed the title Validate return types of all calls to changes/preparations/validations Validate return types of all behavior callbacks May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Up Next
Development

No branches or pull requests

1 participant