Closed kaleidawave closed 2 months ago
@kaleidawave please assign me this issue
@kaleidawave @n-keerthi-gayathri Hey, I'm interested in taking on this task as my first contribution. I'll be following the detailed steps in the issue description, but I'll post again if I run into any issues.
putting these together because they are pretty much the same implementation
Default parameter value
currently no exception is raised here
it should raise an exception for the default parameter value, as the RHS is not subtype-able under
number
the code is here, using
type_is_subtype
withparameter_constraint
againstvalue
(default_value) and sending the result tochecking_data.diagnostics_container
with the position usingA::expression_position
https://github.com/kaleidawave/ezno/blob/b6ead3efaebbfa8c1692f296e30860b3be10f17c/checker/src/features/functions.rs#L136-L147
Catch variable
currently no exception is raised here
it should raise an exception here
5
is RHS is not subtype-able undernumber
the code should go here https://github.com/kaleidawave/ezno/blob/b6ead3efaebbfa8c1692f296e30860b3be10f17c/checker/src/synthesis/statements.rs#L250
The shape of code
Here you can see how it is done for
x satisfies Type
. You simply want to import thetype_is_subtype
function and give the type from the annotation as the LHS type/first argument, then follow the rest.https://github.com/kaleidawave/ezno/blob/b6ead3efaebbfa8c1692f296e30860b3be10f17c/checker/src/types/subtyping.rs#L760-L764
and emitting the error diagnostic
https://github.com/kaleidawave/ezno/blob/b6ead3efaebbfa8c1692f296e30860b3be10f17c/checker/src/lib.rs#L382-L400
You want to create custom
TypeCheckErrors
for both these scenarios, to annotate that it was aInvalidDefaultValue
orThrowDoesNotMatchCatchVariableAnnotation
You also want to add tests to
specification.md
for the cases above.As with any issue, if you want more help or questions feel free to ask