Dependent typing and Refinement Typing for D
sighoya at gmail.com
Sat Dec 21 13:13:26 UTC 2019
>Wouldn't the problem be exactly the same? You need to deduce
>what the arguments are within the constraints, so you need to
>analyze all paths that led to the value you submit to the
>function to establish such constraint.
If you suggest to take values from the function body into the
return value expression, then no, we shouldn't allow this.
What happens if we have a constant value expression in the
function signature return value, then we need to check indeed all
possible paths leading to this value, therefore I would only use
it for unit tests as unit tests could be executed at compile time
then (because of constants inputs).
Another option would be to add a runtime assertion before
returning a value inside the function block.
More information about the Digitalmars-d