Skip to content

Conversation

@uhoreg
Copy link
Contributor

@uhoreg uhoreg commented Nov 28, 2025

Fixes errors with certain schemas. I don't remember exactly what the schemas were that caused the errors. One of them was a union where one of the types was a custom type that was a cast or a union itself.

type = new(opts)
constraints =
case type.constraints do
{:and, constraints} -> {:and, constraints ++ infer_constraints(predicates)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the minimal changes to make this work. But it looks like {:and, constraints} gets treated the same as just constraints, so I wonder if we can just get rid of {:and, ...} everywhere.

@doc since: "0.1.0"

@spec type({atom(), []}) :: type()
@spec type({atom(), list()}) :: type()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Elixir docs say that a typespec of [] means an empty list.


defp constrain(%Drops.Types.Cast{input_type: input_type} = type, predicates) do
Map.merge(type, %{
input_type: constrain(input_type, predicates)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure if the constraint should be applied to the input type, the output type, or both.

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.

1 participant