Check using the type annotation for default parameter value and try-catch variable #112
Labels
checking
Issues around checking
enhancement
New feature or request
good-first-issue
PRs welcome 🙏
subtyping
Related to comparing two types
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
ezno/checker/src/features/functions.rs
Lines 136 to 147 in b6ead3e
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
ezno/checker/src/synthesis/statements.rs
Line 250 in b6ead3e
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.ezno/checker/src/types/subtyping.rs
Lines 760 to 764 in b6ead3e
and emitting the error diagnostic
ezno/checker/src/lib.rs
Lines 382 to 400 in b6ead3e
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
The text was updated successfully, but these errors were encountered: